C++
This
GOD03219
2018. 9. 12. 15:22
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 |
#include<iostream>
#include<string.h>
#include<cstdlib>
using namespace std;
/*
this pointer: 메소드의 첫번째 매개변수로 선언되어있다.
*/
class Obj{
int a;
public:
Obj(int a=0){this->a=a;}
void setA(int a){ // void setA(Obj * this, int a)
this->a=a;
}
int getA(){
return a;
}
};
void main(){
Obj obj;
Obj obj2(100);
// obj.setA(100); // obj.setA(&obj, 100);
cout << obj. getA() << endl;
cout << obj2. getA() << endl;
}
|
cs |