中易网

C++: error C2064: term does not evaluate to a function

答案:1  悬赏:70  
解决时间 2021-02-18 13:22
文件一:Teacher.h #include<iostream> #include<string> using namespace std; class Teacher { private: string name; int age; char sex; string address; string phone; string title; public: Teacher(string a="abcd",int b=1,char c='W',string d="abcd",string e="abcd",string f="abcd") { name=a; age=b; sex=c; address=d; phone=e; title=f; } void display(); }; 文件二:Cadre.h #include<iostream> #include<string> using namespace std; class Cadre { private: string name; int age; char sex; string address; string phone; protected: string post; public: Cadre(string a="abcd",int b=10,char c='W',string d="abcd",string e="abcd",string f="abcd") { name=a; age=b; sex=c; address=d; phone=e; post=f; } }; 文件三:Teacher_Cadre.h #include<iostream> #include"Teacher.h" #include<string> #include"Cadre.h" using namespace std; class Teacher_Cadre:public Teacher,public Cadre { private: int wages; Teacher t1; Cadre c1; public: Teacher_Cadre(string a,int b,char c,string d,string e,string f,string g,int h) { t1(a,b,c,d,e,f); // error C2064: term does not evaluate to a function c1(a,b,c,d,e,g); // error C2064: term does not evaluate to a function wages=h; } void show() { display(); cout<<"post:"<<post<<endl; } } 文件四:display.cpp #include<iostream> #include"Teacher.h" #include<string> using namespace std; void Teacher::diplay() { cout<<"name:"<<name<<endl; cout<<"age:"<<age<<endl; cout<<"sex:"<<sex<<endl; cout<<"address:"<<address<<endl; cout<<"phone:"<<phone<<endl; cout<<"title:"<<title<<endl; } 文件五:main.cpp #include<iostream.h> #include"Teacher_Cadre.h" using namespace std; int main() { Teacher_Cadre x1("xiaoli",20,'M',"sichuan","123456789","wu","student",0); x1.show(); return 0; }
最佳答案
构造函数不是这样构造的,你都还没创建对象,怎么能用 t1(a,b,c,d,e,f);呢?
改成如下的就OK了:
Teacher_Cadre(string a,int b,char c,string d,string e,string f,string g,int h)
{
//t1(a,b,c,d,e,f); // error C2064: term does not evaluate to a function
//c1(a,b,c,d,e,g); // error C2064: term does not evaluate to a function
Teacher(a,b,c,d,e,f);
Cadre(a,b,c,d,e,f);
wages=h;
}

自己再好好想想,参考下书~
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
甘肃申欣健康职业培训学校简介
艾欧宾馆我想知道这个在什么地方
兰兰家在学校南面五百米处,方方家在兰兰家北
淑兰超市我想知道这个在什么地方
540÷3的竖式加验算怎么做?
开心消消乐我用的电信的手机,用的是微信号是
在新的历史起点上,中国如何保持经历中高速发
班干部竞选词!
家里有低保的,孩子满二十周岁当兵的,家里低保
昨晚梦见家里有一条蛇,可能是买的,记不清了
中国最大的电子股份有限公司有哪些?
唉,少壮不努力,老大耍流氓,我就不回答从来
威志夏利销售服务店(辽源东辽县)怎么去啊,我
谁知道有的大学一些老师会有学生名额指标是怎
有首歌歌词是这样的 我就在你家的楼下,雨滴
推荐资讯
使场面火热的热闹的近义词
二楼的业主说坏人可以从我一楼的室外机攀爬上
如何该和领导提工资的事?
当女朋友提出分手,该怎么正确的方法去挽留
证明是梯形的条件是不是 上底面和下地面是平
美景山城西区怎么去啊,有知道地址的么
开源印刷在什么地方啊,我要过去处理事情
顺丰什么时候开始外卖
我是卖家,买家收到货后的货款是打到我的支付
英雄联盟7.3版本的符文在哪里?实在找不到
聚龙城这个地址在什么地方,我要处理点事
带走,去,人,字搞笑的话有哪些
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?