![]() |
#2
pangding2012-07-28 17:39
|

#include <iostream>
#include <Windows.h>
using namespace std;
int main(void)
{
system("cls");
const int a = 1;
const int &b = a;
cout << &a << " VS " << &b << endl;
const float a1 = 1.0;
const int &b1 = a1;
cout << &a1 << " VS " << &b1 << endl;
int a2 = 1;
const int &b2 = a2;
cout << &a2 << " VS " << &b2 << endl;
int a3 = 1;
int &b3 = a3;
cout << &a3 << " VS " << &b3 << endl;
const int a4 = 1.0;
int &b4 = a4;
cout << &a4 << " VS " << &b4 << endl;
system("pause");
return 0;
}
#include <Windows.h>
using namespace std;
int main(void)
{
system("cls");
const int a = 1;
const int &b = a;
cout << &a << " VS " << &b << endl;
const float a1 = 1.0;
const int &b1 = a1;
cout << &a1 << " VS " << &b1 << endl;
int a2 = 1;
const int &b2 = a2;
cout << &a2 << " VS " << &b2 << endl;
int a3 = 1;
int &b3 = a3;
cout << &a3 << " VS " << &b3 << endl;
const int a4 = 1.0;
int &b4 = a4;
cout << &a4 << " VS " << &b4 << endl;
system("pause");
return 0;
}
大家先 目测下 这5种方式的引用是不是都成立 如果成立那么输出的结果都是些什么 ?