I am having a base class that has 5 subclasses.
If in my base class I have this:
virtual CpuPort &getsecondDataPort()=0;
then this means that the method has to be implemented for all the subclasses, right?
But I do not want that, since I know that I will call that method only when I have an object of the specific subclass so I thought that I could write this instead:
virtual CpuPort &getsecondDataPort();
and implement it only in the subclass I want. But that gives me this error:
/base.cc:254: undefined reference to `vtable for BaseCPU'
and in the from the other subclasses :
undefined reference to `typeinfo for BaseCPU'
where BaseCPU is my object of the base class.
Because it is part of a bigger library (simulator actually), I want to make as fewer changes as possible. So please do not suggest something like 'define that oonly in your subclass' as I want to follow the way code is organized so far, unless this is the only way of fixing the problem.
Any idea on why that might happen?
Thanks