I was studying an example of Singleton Pattern in c++.
class Singleton
{
private:
static Singleton oneandonly;
Singleton(){};
~Singleton(){};
Singleton(const Singleton &);
Singleton & operator= (const Singleton &);
public:
static Singleton &getInstance(){ return oneandonly; };
}
I do not understand what following line do.
Singleton(const Singleton &);
I always used const for methods but now is for the formal parameter of the method, and the '&' does have any particular meaning or is just an odd name.
And then the line:
static Singleton &getInstance(){ return oneandonly; };
Why there is a & in front of the method?