Double linked list in c++ with inheritance

215 Views Asked by At

I try to solve Jopsephus problem and i need a circular double linked list, but i do not know how to do the following thing: I got these classes:

class node
{
private:
    int info;
    nod *next;
}


class double_nod: public node
{
private:
    nod *previous;}

class List
{
private:
    double_node* first_node;
    double_node* current_node;
    int length;}

I am trying to do a function that return the next double_node from the list but I get an error in the function below because node cannot be converted to double_node :

void List::get_next_node()
{
    if(current_node->get_urm()!=NULL) // get_urm() is from class node and return next
    {
        current_node=current_node->get_urm();
    }
}

Any ideea? I got a homework to do and OOP is way too hard for me at the beginning.

0

There are 0 best solutions below