A& B =
C::Instance()-> D;
I have this line of code that I am suppose to write an algorithm for, but I don't understand what C::Instance() means or does. Could someone help me understand this line?
A& B =
C::Instance()-> D;
I have this line of code that I am suppose to write an algorithm for, but I don't understand what C::Instance() means or does. Could someone help me understand this line?
On
Static member function ::Instance() is usually implemented when we need just 1 instance of a class and is implemented in a way that follows singleton implementation.
Instanceis a static member function ofC.It returns a pointer to something that has a member variable
D, andDis of either typeAorA&.The thing
Instancereturns is probably the only existing instance ofCitself, making the instance a singleton.(But that's a guess based on the name and the usage.)