获取错误:ISO C++禁止无类型的声明
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
}
相关文章:
- 将类型声明为类型模板参数的模板参数的一部分是否合法?
- 当返回类型声明为 ListNode 时,我们是否可以返回 false<T>*
- 如何使用自定义类型声明Arduino数组?
- 将函数参数类型声明为 auto
- 使用typedef'ed返回类型声明友元函数时出现编译器错误
- 在没有标识符的情况下如何读取复杂的C++类型声明?
- 模板函数参数显式类型声明
- 使用指针遍历一系列基元类型声明?
- 字符类型声明和验证
- 使用本地类型声明的G lambda被使用但从未定义 - 确实是一个错误
- 为什么 c++ lambda 捕获不需要类型声明?
- 为什么没有"int"类型声明时输出不同?
- C++如何使用虚拟基类型声明全局静态分配的变量
- 我可以使用预处理器将一个类型声明替换为另一个类型声明吗?
- 如何将数据类型声明从.cpp文件传输到 .cu 文件
- C++17 枚举类型声明
- 条件类型声明
- 具有特定参数的特定构造函数的类型声明
- 我可以使用相同的名称为周围作用域中的类型声明成员类型别名吗
- 函数调用之前,C 类型声明