I have an inheritance problem that looks like this:
base
/ \
/ \
derv1 derv2
I have some functions in base that I want to be usable by both derv1 and derv2. However, some of these functions iterator through a vector of derv1* or derv2* and access some functions inside of them. Is there a way I can make this work or am I stuck just making the functions virtual and copy/pasting the code into the derived classes?
You can move the function outside the class and add a template parameter to get the right iterator.
Then you make that function virtual and on each class call the function passing what you want as template argument