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 54
|
using namespace std;
typedef struct { int x; int y; }Coord;
void (int &a, int &b);
int main(int argc, const char * argv[]) {
int a = 10; int &b = a; b = 20; cout << a << endl; cout << b << endl;
Coord c; Coord &c1 = c; c1.x = 20; c1.y = 30; cout << c.x << ' ' << c.y << endl;
int a1 = 10; int a2 = 40;
cout << a1 << ' ' << a2 << endl; func(a1, a2); cout << a1 << ' ' << a2 << endl;
return 0; }
void (int &a, int &b) { int c = 0; c = a; a = b; b = c; }
|
http://blog.csdn.net/Simba888888/article/category/1464971/4
近期评论