依存関係の問題があります。と の 2 つのクラスがGraphic
ありImage
ます。それぞれに独自の .cpp および .h ファイルがあります。私はそれらを次のように宣言しています:
Graphic.h
:
#include "Image.h"
class Image;
class Graphic {
...
};
Image.h
:
#include "Graphic.h"
class Graphic;
class Image : public Graphic {
...
};
コンパイルしようとすると、次のエラーが発生します。
Image.h:12: エラー: '{' トークンの前にクラス名が必要です
Graphic
fromの前方宣言を削除するとImage.h
、次のエラーが発生します。
Image.h:13: エラー: 不完全なタイプ 'struct Graphic' の無効な使用 Image.h:10: エラー: 'struct Graphic' の前方宣言