Last active
April 28, 2018 04:22
-
-
Save FraGoTe/3663112848c4ac76d13ea8589e474f34 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
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