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

[复制链接]
查看11 | 回复1 | 2010-12-21 14:41:14 | 显示全部楼层 |阅读模式
文件一:Teacher.h
#include
#include
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
#include
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
#include"Teacher.h"
#include
#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
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
#include"Teacher_Cadre.h"
using namespace std;
int main()
{
Teacher_Cadre x1("xiaoli",20,'M',"sichuan","123456789","wu","student",0);
x1.show();
return 0;
}
那个Teacher_Cadre类,最后的分号复制时掉了,但是源程序有的,大家不要找这个错误了

回复

使用道具 举报

千问 | 2010-12-21 14:41:14 | 显示全部楼层
构造函数不是这样构造的,你都还没创建对象,怎么能用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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行