I have a generic linked list that works with various types of data including objects and pointers to objects, etc, but i'm having trouble working with the list when I insert objects from a class that is derived from an abstract class.
I have an abstract class called vehicle and 2 classes that are carr and truck and I can do something like this:
list<vehicle> lv;
vehicle * v1;
vehicle * v2;
v1 = new carr;
v2 = new truck;
cin >> *v1 >> *v2;
//But when I try to insert in the list
lv.insertEnd(*v1);
I have the error:
cannot allocate an object of abstract type 'vehicle'
And the compiler show that the error is in the insertEnd method of my linked list code in the part where I write:
newNode->item = new Item;
This a part of a project where I need to have a list of vehicles and the vehicles can be carrs, trucks, etc. I have the group of vehicles implemented with pointers to pointers but i'm trying to do this with a list of vehicles.
Can you help me?
EDIT: The item is in my linked list, i'll show my insertEnd method:
template <class Item>
void list<Item>::insertEnd(const Item& item)
{
    node<Item> *newNode= new node<Item>;
    newNode->item = new Item;
    *(newNode->item) = item;
    newNode->next = 0;
    if(head == 0)
    {
       head = newNode;
       tail = newNode;
        _size++;
    }
    else
    {
        novoNo->prev = tail;
        tail->next = newNode;
        tail = newNode;
         _size++;
    }
}
 
     
     
    