I am trying to build a zoo for practicing c++ and oop. I have made 2 classes, Animal class (the base class) and Bear class (the derived class). I want to have 2 virtual functions in Animal that I will override in Bear but CLION tells me that 'Function Walk did not decleared in class Bear'.
What do I need to change?
This is the base class (Animal) header:
class Animal { public: Animal(); Animal(string Name, int CageNum, string FoodType, string Gender, bool NeedTreatment); virtual void Talk() = 0; virtual void Walk(); int CageNum; string FoodType; string Gender; bool NeedTreatment; string Name; }; CPP:
Animal::Animal() {}; Animal::Animal(string Name, int CageNum, string FoodType, string Gender, bool NeedTreatment) : Name(Name), CageNum(CageNum), FoodType(FoodType), Gender(Gender), NeedTreatment(NeedTreatment){}; This is the derived class (Bear) header:
#include "Animal.h" class Bear : public Animal{ protected: string FurColor; public: Bear(string Name, int CageNum, string FoodType, string Gender, bool NeedTreatment,string FurColor); }; and this is the CPP:
#include "Bear.h" Bear::Bear(string Name, int CageNum, string FoodType, string Gender, bool NeedTreatment,string FurColor) : Animal(Name, CageNum, FoodType, Gender, NeedTreatment),FurColor(FurColor) {}; void Bear::Walk() { cout << "Bear Moves"; } void Animal::Talk() { "Bear Noise"; }