Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream>

using namespace std;


class Singleton final
{

private:
Singleton()
{
cout << "probando constructor" << endl;
}
public:
static Singleton* getInstancia(void)
{
static Singleton* instancia = NULL;
if (instancia == NULL)
{
instancia = new Singleton();
}
return instancia;
}

};

int main()
{
Singleton* t = Singleton::getInstancia();
Singleton* t1 = Singleton::getInstancia();
if (t == t1)
{
cout << "es lo mismo" << endl;
}
return 0;

You might also like