dev-c++ 问题 ;帮忙看看啊

flowerinwater 2002-07-01 03:17:32
错误信息:
行号:4 C:\cppprojects\4\CElement.cpp
cannot declare member function `CElement::CElement' within `CFunction'

行号:8 C:\cppprojects\4\CElement.cpp
cannot declare member function `CElement::CElement' within `CFunction'

12 C:\cppprojects\4\CElement.cpp
cannot declare member function `CElement::CElement' within `CFunction'

17 C:\cppprojects\4\CElement.cpp
cannot declare member function `CElement::CElement' within `CFunction'

.h文件

using namespace std;
#include <string>
#include <vector>

class CFunction;

class CElement{
public :
CElement();
CElement(string name);
CElement(string id,string name);
~CElement();

virtual string getContent();

void addFunction(CFunction function);
void removeFunction(CFunction function);

const string getId(){return name;};
const string getName(){return name;};
const string getDesc(){return desc;};

void setName(string name);
void setDesc(string desc);

protected:
string id;
string name;
string desc;
int kindOfValue;
vector<CFunction> functions;

public:
const static int KIND_STRING=0;
const static int KIND_CHAR=1;
const static int KIND_INTEGER=2;
const static int KIND_FLOAT=3;
const static int KIND_LONG=4;
};




.cpp文件

#include "CElement.h"
#include "CFunction.h"

CElement::CElement(string name){
CElement("id",name);
}

CElement::CElement(){
CElement("id","null");
}

CElement::CElement(string newid,string newname){
this->id=newid;
this->name=newname;
}

CElement::~CElement(){
}

void CElement::addFunction(CFunction function){
functions.push_back(function);
}

void CElement::removeFunction(CFunction function){
//functions.push_back(function);
}

string CElement::getContent(){
return id + name;
}


...全文
67 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
LeeMaRS 2002-07-01
  • 打赏
  • 举报
回复
:) 可能看到程序出错,急躁了些.没什么的.
flowerinwater 2002-07-01
  • 打赏
  • 举报
回复
我考,原来这样
开来还是基本功夫不扎实
LeeMaRS 2002-07-01
  • 打赏
  • 举报
回复
看到了:

CFunction(string name,string desc){this->name=name,this->desc=desc);

这里少了一个}

难怪会报错误了.
LeeMaRS 2002-07-01
  • 打赏
  • 举报
回复
看到了:
CFunction(string name,string desc){this->name=name,this->desc=desc);

少了一个}

难怪会出现那个提示错误.
flowerinwater 2002-07-01
  • 打赏
  • 举报
回复
CFunction的头文件,具体的实现还没有那
不是想做模板,是想把CFunction作成一簇类,CFunction提供公共的接口(不知道是不是有其他的好办法)


using namespace std;
#include <string>

class CFunction{
private :

protected :
string name;
string desc;
string content;

public :
CFunction();
CFunction(string name,string desc){this->name=name,this->desc=desc);

string getName();
string getDesc();
virtual string getContent();
};
stzhou 2002-07-01
  • 打赏
  • 举报
回复
是不是CFunction的什么地方少加了分号?
LeeMaRS 2002-07-01
  • 打赏
  • 举报
回复
class CFunction;

搞错了吧?????
你是想做模板?

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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