1 |
|
---|
2 | #include <iostream>
|
---|
3 |
|
---|
4 | #include <boost/noncopyable.hpp>
|
---|
5 |
|
---|
6 | class Foo : private boost::noncopyable
|
---|
7 | {
|
---|
8 | public:
|
---|
9 | Foo(const std::string name) : m_name(name) {
|
---|
10 | std::cout << "constructor\n";
|
---|
11 | }
|
---|
12 | Foo(const Foo &other) {
|
---|
13 | m_name = other.m_name + "'";
|
---|
14 | std::cout << "copy-constructor\n";
|
---|
15 | }
|
---|
16 | void print()
|
---|
17 | {
|
---|
18 | std::cout << "<" + m_name + ">\n";
|
---|
19 | }
|
---|
20 | private:
|
---|
21 | int a;
|
---|
22 | std::string m_name;
|
---|
23 | };
|
---|
24 |
|
---|
25 | int main()
|
---|
26 | {
|
---|
27 | std::cout << "Hello World\n";
|
---|
28 | Foo f("f");
|
---|
29 | std::cout << "Now copy the thing\n";
|
---|
30 | Foo g(f);
|
---|
31 | g.print();
|
---|
32 | }
|
---|