forked from arashVsh/AP_Git_Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.cpp
50 lines (42 loc) · 779 Bytes
/
1.cpp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
using namespace std;
class container {
friend class vector;
public:
container() { size = 0; }
float* p;
container(int s) :size(s) {}
int& getsize() { return size; }
protected:
int size;
};
class vector :public container {
int call_num;
public:
explicit vector(int l) :len(l), container(1 * 100) {
p = new float[size];
}
vector(const container& con) :container(1 * 100) {
this->size = size;
this->p = new float[con.size];
len = 0;
}
int len;
//len is useless!!
int& getlen() {
call_num++;
return len;
}
~vector() = default;
};
int main() {
container c1(100);
vector v1 = c1;
container& r1 = v1;
container c2 = 100;
c2.getsize() = 20;
cout << c2.getsize();
vector v2 (100);
v2.getlen() = 40;
cout << v2.getlen();
}