Advertisement
tomasaccini

Untitled

Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <stdlib.h>
  2.  
  3. class A {
  4. public:
  5.     int* p;
  6.     A() {
  7.         p = (int*)malloc(sizeof(int));
  8.         *p = 0;
  9.     }
  10.  
  11.     /*A(A& other) {
  12.         this->p = (int*)malloc(sizeof(int));
  13.         *(this->p) = *(other.p);
  14.     }*/
  15.  
  16.     ~A() {
  17.         if (p)
  18.             free(p);
  19.     }
  20. };
  21.  
  22. int main() {
  23.     A a1;
  24.     A a2(a1);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement