I have a derived derived class from an abstract class. The code is below. I have a FishTank class which is derived from an Aquarium and Aquarium is derived from item. My question is that should I put the definition of virtual int minWidth() const = 0; in aquarium again or is the code below sufficient?
class Item{
public:
virtual int minWidth() const = 0;
};
class Aquarium: public Item{
public:
virtual int calWidth() = 0; // Pure virtual function.
};
class FishTank : public Aquarium{
public:
FishTank(int base1, int base2, int height);
~FishTank();
int calWidth();
int minWidth();
};
There’s no reason to do it again. It only serves to waste space and give you the opportunity to get compile errors from typos. 🙂 Once you inherit, it’s just like it had been there anyway.
However, you don’t actually ever implement it! Why? You’re missing
constinFishTank: