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?
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.
Instance
is a static member function ofC
.It returns a pointer to something that has a member variable
D
, andD
is of either typeA
orA&
.The thing
Instance
returns is probably the only existing instance ofC
itself, making the instance a singleton.(But that's a guess based on the name and the usage.)