I have a skeleton of a project I need to implement a Doubly Linked List (no using stl) and the way the class is implemented is to inherit all is methods from a struct like so:
struct IDoubleList {
virtual IDoubleNode * getHead() = 0;
virtual IDoubleNode * getTail() = 0;
virtual void setHead(IDoubleNode * head) = 0;
virtual void setTail(IDoubleNode * tail) = 0;
virtual void addBack(int value) = 0;
};
class DoubleList : public IDoubleList {
public:
virtual IDoubleNode * getHead();
virtual IDoubleNode * getTail();
virtual void addBack(int value);
virtual void setHead(IDoubleNode * head);
virtual void setTail(IDoubleNode * tail);
private:
DoubleNode* m_Head;
DoubleNode* m_Tail;
};
As you can getters and setters use the struct, not the class to return/pass pointers. My question is how can I use the methods in he object m_Tail is pointing to. I tried using m_Tail.setNext(newNode); where setNext is method in the DoubleNode class but that says the expression must have a class type.
Also when I return/pass a DoubleNode* should I be casting or something to IDoubleNode*? or maybe its the other way around?
PS been a while since ive used C/C++, maybe I'm forgetting something about function pointers? idk so lost right now
Thanks in advanced, let me know if you need any more info