
Untitled
By: a guest on
Aug 9th, 2012 | syntax:
None | size: 0.94 KB | hits: 9 | expires: Never
Check if instance exists and return reference in Singleton getInstance();
class Song {
private:
Song song;
Song();
Song(Song const&); // don't implement
void operator = (Song const&); //don't implement
public:
static Song &getInstance();
}
Song(Song const&); // don't implement
void operator = (Song const&); //don't implement
static S& getInstance()
{
static S instance; // Guaranteed to be destroyed.
// Instantiated on first use.
return instance;
}
Song(Song const&) = delete;
void operator = (Song const&) = delete;
static S& getInstance()
{
static S instance; // Guaranteed to be destroyed.
// Instantiated on first use.
return instance;
}
Song(Song const&);
Song a;
Song b = a; // calls copy constructor
void operator=(const Song&);
Song a;
Song b;
b = a; // calls assignment operator.
Song& operator=(const Song&);