forked from AlirezaPeymanirad/APLabGitPractice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.cpp
More file actions
41 lines (35 loc) · 597 Bytes
/
1.cpp
File metadata and controls
41 lines (35 loc) · 597 Bytes
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
#include <iostream>
using namespace std;
class container {
protected:
int size;
public:
float* p;
container(int s) :size(s){}
int& getsize() { return size;}
};
class vector :public container {
int call_num;
public:
explicit vector(int l) :len(l),container(1 * 100){
p = new float();
}
int len;
int& getlen() {
call_num ++;
return len;
}
~vector() = default;
};
int main() {
container c1(100);
vector vc1(1);
vector v1 = vc1;
container& r1 = v1;
container c2 = 100;
c2.getsize() = 20;
cout << c2.getsize();
vector v2 ( 100);
v2.getlen() = 40;
cout << v2.getlen();
}