简体   繁体   English

获取错误:ISO C ++禁止声明无类型

[英]Getting error: ISO C++ forbids declaration of with no type

I'm getting the following errors: 我收到以下错误:

ISO C++ forbids declaration of ttTreeInsert with no type ISO C ++禁止声明ttTreeInsert没有类型

ISO C++ forbids declaration of ttTreeDelete with no type ISO C ++禁止在没有类型的情况下声明ttTreeDelete

ISO C++ forbids declaration of ttTreePrint with no type ISO C ++禁止在没有类型的情况下声明ttTreePrint

prototype for int ttTree::ttTreePrint() does not match any in class ttTree int ttTree的原型:: ttTreePrint()与类ttTree中的任何一个都不匹配

candidate is: void ttTree::ttTreePrint() 候选人是:void ttTree :: ttTreePrint()

Here is my header file: 这是我的头文件:

#ifndef ttTree_h
#define ttTree_h

class ttTree 
{
public:
  ttTree(void);
  int ttTreeInsert(int value);
  int ttTreeDelete(int value);
  void ttTreePrint(void);

};

#endif

Here is my .cpp file: 这是我的.cpp文件:

#include "ttTree.h"

ttTree::ttTree(void)
{

}

ttTree::ttTreeInsert(int value)
{
}

ttTree::ttTreeDelete(int value)
{
}

ttTree::ttTreePrint(void)
{
}

Can anyone point out what is causing these errors? 任何人都可以指出导致这些错误的原因吗? Thank you! 谢谢!

You forgot the return types in your member function definitions: 您忘记了成员函数定义中的返回类型:

int ttTree::ttTreeInsert(int value) { ... }
^^^               

and so on. 等等。

Your declaration is int ttTreeInsert(int value); 你的声明是int ttTreeInsert(int value);

However, your definition/implementation is 但是,您的定义/实现是

ttTree::ttTreeInsert(int value)
{
}

Notice that the return type int is missing in the implementation. 请注意,实现中缺少返回类型int Instead it should be 相反它应该是

int ttTree::ttTreeInsert(int value)
{
    return 1; // or some valid int
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM