Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. class foo
  2. {
  3.   int name;
  4.  
  5. public:
  6.   foo(void): name(0xF00){};
  7.   ~foo(void){};
  8. };
  9.  
  10. class bar
  11. {
  12.   foo f1;
  13.   foo *f2;
  14.  
  15.  public:
  16.   bar(void):f2(new foo()){};
  17.   bar(bar& b){
  18.     f1 = b.f1; *f2=*b.f2;
  19.   }
  20.   ~bar(void){delete f2;};
  21.   bar& operator=(bar& b)
  22.   {
  23.     bar *tmp = new bar();
  24.    
  25.     tmp->f1 = b.f1;
  26.     *tmp->f2 = *b.f2;
  27.     delete f2;
  28.  
  29.     return *tmp;
  30.   };
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement