c++改错42

来源:百度知道 编辑:UC知道 时间:2024/06/28 17:33:28
42.#include<iostream.h>
class f{
private:int x,y;
public:f1( ){x=0;y=0;}
print( ){cout<<x<<〃<<y<<endl;}
}
main( ){
f a;
a.f1(1,1);
a.print( );
}

你的函数f()的定义里面并没有参数,你应该改为这样的定义f(int x,int y)

#include<iostream.h>//缺少using namespace std;
class f{
private:int x,y;
public:f1( ){x=0;y=0;}
print( ){cout<<x<<〃<<y<<endl;} //〃错误
} //此处少了分号;
main( ){ //main()前要有void,写作void main()
f a;
a.f1(1,1); //类中缺少重载函数void f1(int, int);
a.print( );
}