Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@FraGoTe
Last active April 28, 2018 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FraGoTe/3663112848c4ac76d13ea8589e474f34 to your computer and use it in GitHub Desktop.
Save FraGoTe/3663112848c4ac76d13ea8589e474f34 to your computer and use it in GitHub Desktop.
int main()
{
cout << "***Entramos a main" << endl;
Prueba objeto(0);
{
cout << "***Entramos al bloque" << endl;
Prueba objetoA(1);
Prueba objetoB(2);
cout << "***Salimos del bloque" << endl;
}
Prueba *ptr; //creamos un puntero.
ptr = new Prueba(3);//le asignamos un objeto dinamicamente, con argumento 3.
Prueba *ptr2;
ptr2 = new Prueba(4);//segundo puntero.
//AHORA LIBERAMOS LA MEMORIA DINAMICA QUE HABIAMOS SOLICITADO, USANDO DELETE.
cout << "--Borramos ptr2" << endl;
delete ptr2;
cout << "--Borramos ptr" << endl;
delete ptr;
cout << "***Ahora estamos por salir de main(), al salir se ejecutara el destructor" << endl << "del objeto 0 creado al principio de main()" << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment