您的位置:首页 > 其它

第三周阅读程序 (1)

2015-03-25 08:04 127 查看
代码

class Test
{
private:
int x, y;
public:
void setX(int a)
{
x=a;
}
void setY(int b)
{
y=b;
}
void printXY(void)
{
cout<<"x="<<x<<'\t'<<"y="<<y<<endl;
}
} ;
int main()
{
Test p1;
p1.setX(3);
p1.setY(5);
p1.printXY( );
return 0;
}




总结:私有成员不能被外界调用,只能通过公有函数来为它们赋值
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: