i have a program with the following inheritance structure
List
/ \
DoublyLinkedList CircularlyLinkedList
\ /
CircularlyDoublyLinkedList
In the List
class (which is fully abstract) I have a pure virtual function
int virtual insert(List **head, int position) = 0;
which I have overridden in the DoublyLinkedList
and CircularlyLinkedList
classes.
In order to resolve ambiguity in the CircularlyDoublyLinkedList
class, I explicitly specify which version of the insert()
function to inherit using the scope resolution operator ::
, for example: DoublyLinkedList::insert(..)
My problem is that this statement
List *cdll_head = new CircularlyDoublyLinkedList();
throws an error
"cannot convert CircularlyDoublyLinkedList* to List*"
when I change the statement as
CircularlyDoublyLinkedList *cdll_head = new CircularlyDoublyLinkedList();
I get another error as insert(...)
accepts a parameter of type List**
How do I resolve this problem without a cast?