structptr.cc

来自「资深C++讲师授课代码」· CC 代码 · 共 20 行

CC
20
字号
#include <iostream>
using namespace std;

struct Date{
	int year;
	int month;
	int day;
};
int main()
{
	Date d1={2008,8,14}, d2={2005,10,1};
	Date* p=NULL;
	p = &d1;// p point to d1
	cout << (*p).year << '-' << (*p).month << '-' << (*p).day << endl;
	cout << p->year << '-' << p->month << '-' << p->day << endl;
	p = &d2;
	cout << p->year << '-' << p->month << '-' << p->day << endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?