[英]Getting error: ISO C++ forbids declaration of ‘type name’ with no type
[英]Getting error: ISO C++ forbids declaration of with no type
我收到以下错误:
ISO C ++禁止声明ttTreeInsert没有类型
ISO C ++禁止在没有类型的情况下声明ttTreeDelete
ISO C ++禁止在没有类型的情况下声明ttTreePrint
int ttTree的原型:: ttTreePrint()与类ttTree中的任何一个都不匹配
候选人是:void ttTree :: ttTreePrint()
这是我的头文件:
#ifndef ttTree_h
#define ttTree_h
class ttTree
{
public:
ttTree(void);
int ttTreeInsert(int value);
int ttTreeDelete(int value);
void ttTreePrint(void);
};
#endif
这是我的.cpp文件:
#include "ttTree.h"
ttTree::ttTree(void)
{
}
ttTree::ttTreeInsert(int value)
{
}
ttTree::ttTreeDelete(int value)
{
}
ttTree::ttTreePrint(void)
{
}
任何人都可以指出导致这些错误的原因吗? 谢谢!
您忘记了成员函数定义中的返回类型:
int ttTree::ttTreeInsert(int value) { ... }
^^^
等等。
你的声明是int ttTreeInsert(int value);
但是,您的定义/实现是
ttTree::ttTreeInsert(int value)
{
}
请注意,实现中缺少返回类型int
。 相反它应该是
int ttTree::ttTreeInsert(int value)
{
return 1; // or some valid int
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.