![](/img/trans.png)
[英]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.