自考新教材-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;
}
运行结果:

 
                    
                     
                    
                 
                    
                
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号