What does ::Instance() mean?

7.8k views Asked by At
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?

2

There are 2 answers

0
molbdnilo On

Instance is a static member function of C.
It returns a pointer to something that has a member variable D, and D is of either type A or A&.
The thing Instance returns is probably the only existing instance of C itself, making the instance a singleton.
(But that's a guess based on the name and the usage.)

1
Saroja Gopali 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.