2013-05-02 87 views
0

我只是在C++中做一個簡單的繼承例子。我使用Xcode和每當我創建一個子類時,我得到的錯誤:使用未聲明的標識鼠。這些都是我的課:C++中的類繼承?

Pet.h

#include <iostream> 
#include <string> 

using namespace std; 

class Pet 
{ 
    public: 
    // Constructors, Destructors 
    Pet(): weight(1), food("Pet Chow") {} 
    ~Pet() {} 

    //General methods 
    void eat(); 
    void speak(); 

    protected: 
     int weight; 
     string food; 
}; 

Rat.h

#include <iostream> 
#include "Pet.h" 

using namespace std; 

class Rat::public Pet 
{ 
    Rat() {} 
    ~Rat() {} 
    // Other methods 
    void sicken() { cout << "Spreading plague" << endl; } 
} 
+0

謝謝。那太愚蠢了......對我感到羞恥 – ivantxo 2013-05-03 23:06:23

回答

2

我想你的意思

class Rat : public Pet 
0
class Rat::public Pet 

應該

class Rat: public Pet