源程序:
#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;
}
运行结果: