In the code below, class D1 inherits from class A.
A has a virtual function and a data member FileCount. So D1 inherits both.
I am keeping the interface implementation unchanged for D1, however for data member FileCount, I'd like to use a different value for D1 than the base class.
class D1 : public A
{
public:
int FileCount; //this is another member. It's hiding the one inherited
D1()
{
FileCount = 100;
}
};
To achieve the effect you want, D1 must provide an implementation for VerifyInventoryData().
¿and do what?
However you should not care about members of the parent class. It introduces an even higher coupling.
You should let the parent to handle it. ¿what it is used for?
@kbw - What if VerifyInventoryData()'s implementation is same for the entire hierarchy - you don't need to define VerifyInventoryData() for D1 then, right?
@ne555 - Thanks for pointing it out - I removed D1::FileCount. I did figure out what I missed.
Here's what I needed to do, in order to get results as I needed:
1 2 3 4 5 6 7 8 9
class D1 : public A
{
public:
D1()
{
A::FileCount = 100;
}
};