blob: 1a2d87b77ba759bfc5724cc584c603abbb777ae9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <iostream>
#include <string>
using namespace std;
class Simple
{
public:
Simple(const int &c_age, const string &c_dest) : age(c_age), dest(c_dest) {}
~Simple() { cout << "Bye!\n"; }
const int& ageRet(void) const;
const string& destRet(void) const;
private:
const int age;
const string dest;
};
const int& Simple::ageRet(void) const
{
return age;
}
const string& Simple::destRet(void) const
{
return dest;
}
int main(void)
{
Simple *ppl_me = new Simple(21, "Truth");
Simple ppl_cpy = *ppl_me;
cout << ppl_cpy.ageRet() << endl;
return 0;
}
|