[ create a new paste ] login | about

Link: http://codepad.org/f2oCL8Tr    [ raw code | output | fork ]

hecomi - C++, pasted on Nov 28:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

class hoge {
   int _n;
public:
   hoge(int n) : _n(n) {}
   void set(const hoge& h) {
      _n = h._n; // h._n is a private member
   }
   int get() const {
      return _n;
   }
};

int main() {
   hoge h1(1), h2(2);
   h1.set(h2);
   std::cout << h1.get() << std::endl;
   return 0;
}


Output:
1
2


Create a new paste based on this one


Comments: