forked from vahidah/debugCodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.cpp
More file actions
40 lines (33 loc) · 574 Bytes
/
1.cpp
File metadata and controls
40 lines (33 loc) · 574 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
#include <iostream>
using namespace std;
class container {
int size;
public:
float* p;
container(int s) :size(s){}
const int& getsize() { return size;}
};
class vector :public container {
int call_num;
public:
explicit vector(int l) :len(l),size(1 * 100){
p = new float();
}
int len;
int& getlen() const {
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();
}