多重继承派生类
#include<iostream>#include<string>
using namespace std;
class teacher
{public:
teacher(string nam,int a,string til):name(nam),age(a),title(til){}
void display()
{cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"title:"<<title<<endl;
}
protected:
string name;
int age;
string title;
};
class student
{public:
student(string nam,int s1)
{strcpy(name1,nam);
score=s1;
}
void display1()
{cout<<"name:"<<name1<<endl;
cout<<"score:"<<score<<endl;
}
protected:
string name1;
int score;
};
class grade:public teacher,public student
{public(string nam,int a,string til,int s1,float w):teacher(nam,a,til),student(nam,s1),wage(w){}
void show()
{display();
display1();
cout<<"wage:"<<wage<<endl;
}
private:
float wage;
};
int main()
{grade grad1("zhangfei",25,"assistant",89,10224);
grad1.show();
return 0;
}
哪位兄弟帮忙看下,这个程序调试时老是出现错误,谢谢了!
错误方式为
--------------------Configuration: paishenggouzhaohanshu - Win32 Debug--------------------
Compiling...
duochongjicheng.cpp
C:\Documents and Settings\Administrator\桌面\GGG\duochongjicheng.cpp(19) : error C2664: 'strcpy' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\Documents and Settings\Administrator\桌面\GGG\duochongjicheng.cpp(34) : error C2320: expected ':' to follow access specifier '('
C:\Documents and Settings\Administrator\桌面\GGG\duochongjicheng.cpp(34) : error C2226: syntax error : unexpected type 'string'
C:\Documents and Settings\Administrator\桌面\GGG\duochongjicheng.cpp(34) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
C:\Documents and Settings\Administrator\桌面\GGG\duochongjicheng.cpp(44) : error C2660: 'grade::grade' : function does not take 5 parameters
Error executing cl.exe.
duochongjicheng.obj - 5 error(s), 0 warning(s)