I'm not being able to properly access dynamic binding from inside one of my derived classes member function definition.
CContainer is a derived of CItem. The former adds a ContentsWeight() member.
CContainer also adds a add() member. And this is where I'm having troubles:
I can understand why I can't do this and why I get an error saying that ContentsWeight is not a member of CItem. After all, obj could be some other type of derived object, or the base itself. Only CContainer declares ContentsWeight.Code:CContainer& CContainer::add(CItem* obj) { /* ... */ int objW = obj->weight() + obj->ContentsWeight(); /* ... */ }
But I'm not sure how to best solve this. I do need to access ContentsWeight on that code.