Advertisement
Dr4noel

Demonstratie

Apr 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. class Nume {
  7.     char*nume;
  8. public :
  9.     Nume(const char *nume) {
  10.         this->nume = new char[strlen(nume) + 1];
  11.         strcpy_s(this->nume,strlen(nume) + 1,nume);
  12.     }
  13.  
  14.     ~Nume() {
  15.         cout << "\nApel Destrctor ";
  16.         afisare();
  17.     }
  18.  
  19.     void afisare() {
  20.         cout << nume;
  21.     }
  22. };
  23.  
  24.  
  25. void main() {
  26.     Nume *persoana = new Nume("David");
  27.     persoana->afisare();
  28.     delete persoana;
  29.  
  30.  
  31.     _getch();
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement