C++ Inheritance question.

Associate
Joined
20 Oct 2002
Posts
2,309
Location
Suffolk
A sad question for a Friday night, but here goes.

I have a class CClass1, which has a member object of type Obj1 defined in its header file.

Now I derive from CClass1 another class, CClass2. This has a member object defined, Obj2 which is derived from Obj1. CClass2 is the class that actually gets instantiated in my code.

Now my question is, do I have to override all of the methods in Class1 that reference Obj1 if I want exactly the same methods in Class2 but referring to Obj2 instead?

Its easy enough to do but seems to generate an awful lot of duplicate code, and was wondering if there was a shortcut that I'm missing.
 
Thanks, I thought you shouldn't, but I seem to be getting errors unless I do override everything. I'll look into it further.
 
Back
Top Bottom