我在使用鏗鏘聲編譯器的C++中發出前向聲明的問題。這是我的代碼。它將CReference成員中的數據指向爲不完整類型。 請幫助向前在C++中聲明類,不完整類型
class Internal;
class CReference {
private:
Internal data;
public:
CReference() {}
~CReference(){}
};
class Internal {
public:
Internal() {}
~Internal() {}
};
你根本不能在這裏使用前向聲明。 'CReference'需要'Internal'的完整聲明。 – juanchopanza
如果你想轉發聲明,你應該使用一個指向'Internal'的指針。 – user1520427
可能重複[何時使用前向聲明?](http://stackoverflow.com/questions/553682/when-to-use-forward-declaration) – juanchopanza