不能将参数 1 从“const char [7]”转换为“std::string &”的问题
部分代码如下:基类构造函数:CPerson(string&name,intage,charsex){m_name=name;m_age=age;m_sex=sex;}CP...
部分代码如下:
基类构造函数:
CPerson(string& name, int age, char sex)
{
m_name = name;
m_age = age;
m_sex = sex;
}
CPerson()
{
m_name = "无名";
m_age = 18;
m_sex = 'M';
}
派生类构造函数:
CStudent():CPerson()
{
m_collagename="苏州大学";
m_grade=1;
}
CStudent(string& name, int a, char b, string& collageName, int grade):CPerson(name,a,b)
{
m_collagename=collageName;
m_grade=grade;
}
主函数里的:
CStudent student2("Liming",21,'M',"苏州大学",1); 展开
基类构造函数:
CPerson(string& name, int age, char sex)
{
m_name = name;
m_age = age;
m_sex = sex;
}
CPerson()
{
m_name = "无名";
m_age = 18;
m_sex = 'M';
}
派生类构造函数:
CStudent():CPerson()
{
m_collagename="苏州大学";
m_grade=1;
}
CStudent(string& name, int a, char b, string& collageName, int grade):CPerson(name,a,b)
{
m_collagename=collageName;
m_grade=grade;
}
主函数里的:
CStudent student2("Liming",21,'M',"苏州大学",1); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询