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; }
}
谢谢。那太愚蠢了......对我感到羞耻 – ivantxo 2013-05-03 23:06:23