自考新教材-p87_2

源程序:

#include <iostream>
using namespace std;

class Test
{
int x, y;
public:
void fun(int i, int j)
{
x = i;
y = j;
}
void show()
{
cout << "x=" << x;
if (y > 0)
cout << ",y=" << y;
cout << endl;
}
};
int main()
{
Test a;
a.fun(1,10);
a.show();
a.fun(2,0);
a.show();
system("pause");
return 1;
}

运行结果:

 

posted @ 2020-02-06 14:42  bobo哥  阅读(124)  评论(0)    收藏  举报