gpt4 book ai didi

c++ - 收到错误 : ISO C++ forbids declaration of with no type

转载 作者:IT老高 更新时间:2023-10-28 12:42:46 25 4
gpt4 key购买 nike

我收到以下错误:

ISO C++ forbids declaration of ttTreeInsert with no type

ISO C++ forbids declaration of ttTreeDelete with no type

ISO C++ forbids declaration of ttTreePrint with no type

prototype for int ttTree::ttTreePrint() does not match any in class ttTree

candidate is: 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) { ... }
^^^

等等。

关于c++ - 收到错误 : ISO C++ forbids declaration of with no type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23314409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com