#include<iostream.h>
class date
{ //默认情况下,成员是私有的
int day;
int month;
int year;
};
void main()
{
date today;
today.day=10;
today.month=8;
today.year=1999;
cout<<"/nThe date is"<<today.day<<"/";
cout<<today.month<<"/"<<today.year<<endl;
}
将出现以下错误信息:
date::day is not accessible
date::month is not accessible
date::year is not accessible
--《面向对象编程:C++》