#include <iostream>
#include <stdlib.h>
using namespace std;
typedef struct
{
int x;
int y;
}Coord;
int main(void)
{
Coord c;
Coord &c1 = c;
c1.x = 10;
c1.y = 20;
cout << c.x <<"," <<c.y << endl;
system("pause");
return 0;
}
#include <stdlib.h>
using namespace std;
typedef struct
{
int x;
int y;
}Coord;
int main(void)
{
Coord c;
Coord &c1 = c;
c1.x = 10;
c1.y = 20;
cout << c.x <<"," <<c.y << endl;
system("pause");
return 0;
}
2016-03-31
#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y=x;
//打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
//修改y的值
y = 10;
//再次打印x和y的值
cout<<x<<","<<y<<endl;
return 0;
}写错了也能通过验证 后来修改了下
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y=x;
//打印x和y的值
cout<<x<<endl;
cout<<y<<endl;
//修改y的值
y = 10;
//再次打印x和y的值
cout<<x<<","<<y<<endl;
return 0;
}写错了也能通过验证 后来修改了下