第1个回答 2009-12-02
#include<iostream>
using namespace std;
class Sample
{
public:
Sample(int a=0,int b=1);
void disp();
private:
int x,y;
};
Sample::Sample(int a,int b)
{
x=a;y=b;
}
void Sample::disp()
{
cout<<"x="<<x<<",y="<<y<<endl;
}
int main()
{Sample g;
g.disp();
return 0;
}
这程序是用默认参数的构造函数,我不知道你的主函数是不是这,如果不是,你在补充一下 ,希望被评为最佳