我有3個類在C++編碼。它們都很簡單,但編譯器給出了很多錯誤。 cpp文件和頭文件中的每個類。可能的問題是什麼? 其中之一是「基類未定義」。簡單的類導致錯誤
class re {
int i;
int j;
string a;
re(int,int,int);
~re();
}
class Pre:public re {
int k;
public:
Pre(int,int,int);
~Pre();
}
class MPre:public Pre {
int z;
public:
MPre(int);
~Mpre(int);
}
類定義應以分號(「;」)結尾。你在實際的代碼中使用了分號嗎? (你沒有在你的例子中使用它)。 – mfontanini 2012-04-19 18:53:35
你可以發佈錯誤,我的意思是你粘貼的可能是因爲在類定義的末尾沒有終止';'但我很難猜測。 – EdChum 2012-04-19 18:53:46
我已經放了分號,仍然有錯誤。 – 2012-04-19 18:55:14