Ray's playground

 

noncopyable implementation in C++

 1 #include <iostream>
 2 using namespace std;
 3 
 4 class noncopyable
 5 {
 6 protected:
 7     noncopyable(){}
 8     ~noncopyable(){}
 9 private:
10     noncopyable(const noncopyable&);
11     const noncopyable& operator=(const noncopyable&);
12 };
13 
14 class myclass : private noncopyable
15 {
16 public:
17     myclass()
18     {
19         cout << "my class" << endl;
20     };
21 };
22 
23 int main()
24 {
25     myclass o;
26     //myclass o2(o);
27     //myclass o3 = o;
28     cin.get();
29 }

posted on 2011-03-13 16:20  Ray Z  阅读(269)  评论(0)    收藏  举报

导航