Last active
September 8, 2023 12:40
-
-
Save naga-karupi/b49072a10658a2fcb66cbba0ad06b89d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class Singleton | |
{ | |
Singleton() | |
{ | |
cout << "Hello Singleton"; | |
} | |
~Singleton() | |
{} | |
public: | |
Singleton(Singleton&) = delete; | |
Singleton(Singleton&&) = delete; | |
Singleton& operator = (Singleton&) = delete; | |
Singleton& operator = (Singleton&&) = delete; | |
static Singleton& get() | |
{ | |
static Singleton s; | |
return s; | |
} | |
}; | |
int main() | |
{ | |
Singleton::get(); | |
Singleton::get(); | |
Singleton::get(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment