#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”中没有找到重载的成员函数