自考新教材-p86_3(1)

源程序:

#include <iostream>
using namespace std;
class Test
{
private:
int x, y;
public:
Test(int i, int j)
{
x = i;
y = j;
}
int getx()
{
return x;
}
int gety()
{
return y;
}
};

int main()
{
Test mt(10,20);
cout << mt.getx();
cout << mt.gety() << endl;
system("pause");
return 1;
}

运行结果:

原文地址:https://www.cnblogs.com/duanqibo/p/12268633.html