我有一個關於在C++代碼中包含多頭文件的問題。頭文件C++的多個包含文件
說例如,我有三個類,X,Y,Z。 X和Y是從基類Z中派生出來的。我想在Y中創建一個X的實例。代碼將如下所示。
class Z{some code}
class X:public Z{some code};//here #include header of class Z added
class Y:public Z //here #include header of class Z added as well as of X class
{private:
X* mX;//instance of X
some code};
所以在這個基類的所有方法的多重定義出現。我如何應付這個問題
可能重複的[重定義c + +](http://stackoverflow.com/questions/2823330/redefinition-c) – 2010-05-14 05:46:26