#include<iostream>
using namespace std;
class Student
{public:
Student(string nam,int a,string t)
{
name=nam;
age=a;
title=t;
}
void display()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"title:"<<title<<endl;
}
protected:
string name;
int age;
string title;
};
class Teacher
{public:
Teacher(char nam[],char s,float sco)
{strcpy(name1,nam);
sec=s;
score=sco;}
void display()
{cout<<"name:"<<name1<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"score:"<<score<<endl;
}
protected:
string name1;
char sex;
float score;
};
class Graduate:public Student,public Teacher
{public:
Graduate(string nam,int a,string t,char s,float sco,float w):Student(nam,a,t),Teacher(nam,s,soc),wage(w){}
void show()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"score:"<<score<<endl;
cout<<"title:"<<title<<endl;
cout<<"wages:"<<wage<<endl;
}
private:
float wage;
};
int main()
{
Graduate grad1("wang-li",24,"assistant",'f',89.5,1234.5);
grad1.show();
return 0;
}
怎么编写都有2个错误,请求哪位高手帮我改正,谢谢!
ompiling...
xiaofang.cpp
G:\c++Á·Ï°\н¨Îļþ¼Ð (11)\xiaofang.cpp(13) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptabl
e conversion)
G:\c++Á·Ï°\н¨Îļþ¼Ð (11)\xiaofang.cpp(15) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptabl
e conversion)
Error executing cl.exe.
xiaofang.exe - 2 error(s), 0 warning(s)
这是出自课本的一道源程序,要把程序改对比较容易,用指针或者去掉某些多余的东西就可以了,我想知道的是错误的原因??错误那里说的是什么意思??谢谢~