|
|
#include <iostream.h>
class Test
{int x,y;
public:
fun(int i,int j)
{x=i;y=j;}
show()
{cout<<"x="<<x;
if(y)
cout<<",y="<<y<<endl;
cout<<endl;}
};
void main()
{Test a;
a.fun(1);
a.show();
a.fun(2,4);
a.show();
}
|
答案:int i,int j调用时,既有一个参数,也有两个参数,且没有重载,所以参数需要带默认值。所以int i,int j错误。[修改]int i,int j=0//注j只要有一个int类型的数据就行。
|
|