/*
*Copyright (c) 2015,烟台大学计算机学院
*All rights reserved.
*文件名称:.cpp
*作者:孙旭明
*完成时间:2015年3月23号
*版本号:v1.0
*/
#include <iostream>
using namespace std;
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<<endl;
cout<<"y="<<y<<endl;
}
};
int main()
{
Test p1;
p1.setX(3);
p1.setY(5);
p1.printXY( );
return 0;
}
学习心得:
通过公共函数为私有成员赋值, 可能泄露机密