求解决问题
//运行不了啊
#include <iostream>
#include<cstring>
using namespace std;
class Person(){
public:
char name[15];
int age;
char sex[5];
Person(char a,int b,char c)
{
strcpy(name,a);
age=b;
strcpy(sex,b);
}
);
class Teacher:public Person{
public :
double hight;
double weight;
Teacher (char a,int b,char c,double d,double e):Person(a,b,c){
hight=d;
weight=e;
}
void showInfo()
{
cout<<"名字:"<<name<<endl;
cout<<"年龄:"<<age<<endl;
cout<<"身高:"<<hight<<endl;
cout<<"体重:"<<weight<<endl;
cout<<"性别:"<<sex<<endl;
}
};
int main(){
Person per;
Teacher zhang;
cout<<"----------------------个人信息-------------------------------\n";
Teacher("李四",25,"男",175.0,55.0)
zhang.showInfo();
//per.showInfo();
return 0;
}
[解决办法]
把错误提示贴出来让大家瞅瞅就是了~
[解决办法]
- C/C++ code
#include <iostream>#include <cstring>using namespace std;class Person{ public: string name; int age; string sex; Person(string a,int b,string c) { name=a; age=b; sex=c; }};class Teacher:public Person{ public : double hight; double weight; Teacher(string a,int b,string c,double d,double e):Person(a,b,c) { hight=d; weight=e; } void showInfo() { cout<<"名字:"<<name<<endl; cout<<"年龄:"<<age<<endl; cout<<"身高:"<<hight<<endl; cout<<"体重:"<<weight<<endl; cout<<"性别:"<<sex<<endl; }};int main(){ Teacher zhang("李四",25,"男",175.0,55.0); cout<<"------------个人信息---------\n"; zhang.showInfo(); return 0;}