Skip to content

Instantly share code, notes, and snippets.

@naga-karupi
Last active September 8, 2023 12:40
Show Gist options
  • Save naga-karupi/b49072a10658a2fcb66cbba0ad06b89d to your computer and use it in GitHub Desktop.
Save naga-karupi/b49072a10658a2fcb66cbba0ad06b89d to your computer and use it in GitHub Desktop.
#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