objective c - C++ Class inheritance in Xcode? -
i making simple example of inheritance in c++. using xcode , whenever create subclass obtain error: use of undeclared identifier rat. these classes:
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; } }
i think mean
class rat : public pet
Comments
Post a Comment