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
54 lines (44 loc) · 724 Bytes
/
1.cpp
File metadata and controls
54 lines (44 loc) · 724 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
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
using namespace std;
class container {
int size;
public:
float* p;
container(int s = 0) :size(s){}
int& getsize() { return size;}
};
class vector :public container {
int call_num;
public:
vector(int l = 0) :len(l), container(1 * 100) {
p = new float();
}
int len;
int& getlen(){
call_num++;
return len;
}
void set_call(int s)
{
call_num = s;
}
void operator =(container c)
{
this->len = c.getsize();
int a = *(c.p);
this->set_call(a);
}
~vector() = default;
};
int main() {
container c1(100);
vector v1;
v1 = c1;
container& r1 = v1;
container c2 = 100;
c2.getsize() = 20;
cout << c2.getsize();
vector v2 = 100;
v2.getlen() = 40;
cout << v2.getlen();
}