大家好,新手大学生求解啊,这些错误都好奇怪啊

u010391995 2013-04-21 02:16:37
#include <iostream>
#include <string>
using namespace std;
class project
{protected:
string name,daima;
public:
project(string i,string j){name=i;daima=j;}
project(project &P){name=p.name;daima=p.daima;}
void prt(){cout<<name<<daima<<endl;}

};
class stu
{protected:
string xm;int xh;
public:
stu(string i,int j){xm=i;xh=j;}
stu(stu &p){xm=p.xm;xh=p.xh;}
void prt(){cout<<xm<<xh<<endl;}
};
class teacher
{protected:
string xm;string zc;
public:
teacher(string x,string z){xm=x;zc=z;}
teacher(teacher &p){xm=p.xm;zc=p.zc;}
void prt(){cout<<xm<<zc<<endl;}
};
class xuanke:public project,public stu,public teacher
{protected:
int cj;
public:
xuanke(string p-name,string p-daima,string s-xm,int s-xh,string t-xm,string t-zc,int c):\
project(p-name,p-daima),stu(s-xm,s-xh),teacher(t-xm,t-zc),cj(c){}
void prt(){project::prt();stu::prt();teacher::prt();cout<<cj<<endl;}
};
void main()
{project a("数学","111");
stu b("小巫",1110);
teacher c("王敏","教授");
xuanke d("数学","111","小巫",1110,"王敏","教授",90);
d.prt();

}
error C2629: unexpected 'class xuanke ('
error C2334: unexpected token(s) preceding ':'; skipping apparent function body
error C2660: 'xuanke::xuanke' : function does not take 7 parameters
...全文
135 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
酷爱19931209 2013-04-21
  • 打赏
  • 举报
回复
引用 1 楼 sugar13 的回复:
xuanke(string p-name,string p-daima,string s-xm,int s-xh,string t-xm,string t-zc,int c):\ project(p-name,p-daima),stu(s-xm,s-xh),teacher(t-xm,t-zc),cj(c){}这里面的所有的减号-都改成下划线_ 另外project(……
失散糖 2013-04-21
  • 打赏
  • 举报
回复
xuanke(string p-name,string p-daima,string s-xm,int s-xh,string t-xm,string t-zc,int c):\ project(p-name,p-daima),stu(s-xm,s-xh),teacher(t-xm,t-zc),cj(c){}这里面的所有的减号-都改成下划线_ 另外project(project &P){name=p.name;daima=p.daima;}这句话中大写的P要改成小写p,或者后面俩小写p改成大写P
#include <iostream>
#include <string>
using namespace std;
class project
{protected:
string name,daima;
public:
project(string i,string j){name=i;daima=j;}
project(project &p){name=p.name;daima=p.daima;}
void prt(){cout<<name<<daima<<endl;}

};
class stu 
{protected:
string xm;int xh;
public:
stu(string i,int j){xm=i;xh=j;}
stu(stu &p){xm=p.xm;xh=p.xh;}
void prt(){cout<<xm<<xh<<endl;}
};
class teacher
{protected:
string xm;string zc;
public:
teacher(string x,string z){xm=x;zc=z;}
teacher(teacher &p){xm=p.xm;zc=p.zc;}
void prt(){cout<<xm<<zc<<endl;}
};
class xuanke:public project,public stu,public teacher
{protected:
int cj;
public:
xuanke(string p_name,string p_daima,string s_xm,int s_xh,string t_xm,string t_zc,int c):\
project(p_name,p_daima),stu(s_xm,s_xh),teacher(t_xm,t_zc),cj(c){}
void prt(){project::prt();stu::prt();teacher::prt();cout<<cj<<endl;}
};
void main()
{project a("数学","111");
 stu b("小巫",1110);
 teacher c("王敏","教授");
 xuanke d("数学","111","小巫",1110,"王敏","教授",90);
 d.prt();

}

64,666

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧