Programming/[C++]
[C++] Reference(레퍼런스)
iD이드
2018. 3. 21. 16:25

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
|
#include<iostream>
using namespace std;
void change(int &a, int &b);
void main() {
int a = 10;
int b = 20;
int &c = a; //reference 변수 선언 : a를 c로도 부르겠다.
/*change(a, b);
cout << a << endl;
cout << b << endl;*/
/*cout << &a << endl;
cout << &b << endl;
cout << &c << endl;*/
//cout << a << endl;
//cout << b << endl;
//cout << c << endl;
c = b;
cout << a << endl;
cout << b << endl;
cout << c << endl;
}
void change(int &a, int &b) {
int temp;
temp = a;
a = b;
b = temp;
}
|
cs |