c++学习--指针和引用

上代码

#include <iostream>
using namespace std;
int main()
{
	cout << "yes" << endl;
	int a = 12;
	int &c = a; // 取地址
	int *p = &a; // 指针指向地址
	cout << "a=" << a <<  "*p=" << *p <<"c="<< c <<endl;
	*p = 123;
	cout <<  "a="<< a << "*p=" << *p << "c:"<< c << endl;
	cout << "p:" << p;


	system("pause"); // 方便观察
	return 0;
}

运行结果
yes
a=12p=12c=12
a=123
p=123c:123
p:003EFE80请按任意键继续. . .

猜你喜欢

转载自blog.csdn.net/weixin_44433306/article/details/87869426