-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy.cpp
More file actions
42 lines (40 loc) · 664 Bytes
/
copy.cpp
File metadata and controls
42 lines (40 loc) · 664 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
#include "iostream"
using namespace std;
class exam{
private:
int a;int b;
public:
exam(){};
exam(int a, int b):a(a),b(b){
}
int getA();
void setA(int aa);
};
int exam::getA(){
return a;
}
void exam::setA(int aa ){
a=aa;
}
class CCopyTest
{
public:
CCopyTest(int _size):size(_size){data=new int[size];}
~CCopyTest(void){delete []data;}
CCopyTest(const CCopyTest& _copy):size(_copy.size)
{
data=new int[size];
memcpy(data,_copy.data,size);
}//×Ô¶¨Ò忽±´¹¹Ô캯Êý
private:
int size;
int* data;
};
int main()
{
exam aa;
exam *a = new exam(2,3);
a->setA(3);
exam *b = a;
cout<<b->getA();
}