C++函数重载问题

#include "iostream"
#include "string"
using namespace std;

class stu
{
private:
int num;
string name;
int score;
public:
stu(int a=0,string b="unknow",int c=0);
int show()
{
cout<<"Num"<<" "<<"Name"<<" "<<"Score"<<endl;
cout<<num<<" "<<name<<" "<<score<<endl;
return 0;
}
};
stu::stu(int a,string b,int c)
{
num=a;
name=b;
score=c;
}
stu::stu(string b,int c)
{
num=10;
name=b;
score=c;
}

int main()
{
stu stu1(15,"name",10);
stu1.show();
return 0;
}

错误如下
[Error] C:\Users\sh497\Desktop\学习方面\实验一.cpp:29: C2511: “stu::stu(std::string,int)”:“stu”中没有找到重载的成员函数

构造函数只声明了一个
stu(int a=0,string b="unknow",int c=0);

stu::stu(string b,int c) 这个没有对应的声明
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答