現在這是一個奇怪的問題。我兩天前編寫了代碼,然後停下來,然後繼續。在我的頭文件(Fruit.h
)我添加了一個名爲animateGrow()
像這樣的方法:一個類的外部定義錯誤,但它在頭文件中聲明
Fruit.h:
class Fruit {
private:
// Member variables here
public:
// Other methods here
void animateGrow();
};
但是當我嘗試添加同樣的方法在CPP文件,我得到一個錯誤Out-of-line definition of 'animateGrow' does not match any declaration in 'Fruit'
。它在頭文件中聲明,但Xcode似乎無法找到該方法。
Fruit.cpp:
#include "SimpleAudioEngine.h"
#include "Fruit.h"
#include "Tree.h"
using namespace cocos2d;
using namespace CocosDenshion;
Fruit::Fruit() {
// Constructor
}
// Getter Methods
// Setter Methods
// Other Methods
void Fruit::animateGrow() {
// I get an error here when I type it.
}
全碼:(鏈接刪除) (在代碼中,Tree
類存在,因爲它提供了所有其他方法和功能除了animateGrow()
做工精細我錯誤)
你應該關閉這個問題,因爲它對未來用戶的用處是無限的。很高興你修好了,祝你好運。 – 2012-08-09 03:55:49
@DavidRodríguez-dribeas如何關閉一個問題?對不起,我對此並不熟悉。 – alxcyl 2012-08-09 03:56:45
呃...標籤下面沒有鏈接嗎? (這可能是因爲你需要一些聲譽才能做到這一點...如果鏈接不存在,別擔心,別人會關閉它 - 我已經投票結束了,它只需要幾張票:) – 2012-08-09 03:58:13