title: Adding object to a linked list c++
body: <p>I am trying to add a object to my linked list, the problem is I am not sure how also the object its self is a base class with sub classes. Vehicle and Car,Van respectively.</p>
  
  <p>The idea of the program is a vehicle rental system where the user can add a vehicle to the system and set certain variables about the vehicle such as: reg number engine size etc but also if the vehicle is a van or a car you the set further variables depending on the whether its a car or van.</p>
  
  <p>For example if I want to add a Ford Van, I would enter the details such as engine size,model etc then i would specify that its a van allowing me to add further details contained within the van subclass.</p>
  
  <p>If any of you can help me with being able to add an object to a linked list such that it meets the criteria I would be very thankful.</p>
  
  <p>My code to insert a new node.</p>
  
  <pre><code>void linkedList::InsertNode(int regNo,double engine,string model,vehicle_type make)
  {
  Vehicle&lt;int&gt; vehicle(int,double,string,vehicle_type);
  
  //create new node
  nodePtr n=new node;
  //make next point to null
  n-&gt;next=NULL;
  n-&gt;data=vehicle(regNo,engine,model,make);
  
  //if we have a list set current pointer
  if(head!=NULL)
  {
      current=head;
      //checks if end
      while(current-&gt;next!=NULL)
      {
          current=current-&gt;next;
      }
      //connect last node to new node
      current-&gt;next=n;
  }
  else
  {
      //new node is front of list if empty
      head=n;
  }
  }
  </code></pre>
  
  <p>Linkedlist.h</p>
  
  <pre><code>#pragma once
  #include &lt;string&gt;
  
  using namespace std;
  
  
  
  class linkedList
  {
  template&lt;class regNo&gt;;
  friend class Vehicle&lt;int&gt;;
  
  typedef enum{ Car,Van} vehicle_type;
  
  private:
  typedef struct node                                                
  {                                                               
    int data;               
    node* next;             
  }*nodePtr;
  
  nodePtr head;
  nodePtr current;
  nodePtr temp;
  
  public:
  linkedList();
  void InsertNode(int regNo ,double engine,string model,vehicle_type make);
  void SearchNode(int);
  void PrintList();
  void DeleteNode(int delData);
  ~linkedList();
  };
  </code></pre>
  
  <p>vehicle.h</p>
  
  <pre><code>#pragma once
  
  template&lt;class regNo=int&gt;
  class Vehicle
  {
  public:
  typedef enum{ Car,Van} vehicle_type;
  
  protected:
  vehicle_type make;
  string model;
  int regNo;
  double engineSize;
  bool rented;
  
  public:
  Vehicle(vehicle_type  make):model(""),regNo(reg),engineSize(engine),make(make),rented(false){};
  char getMakeModel();
  int getRegNo();
  int getEngineSize();
  bool getRented();
  bool setRented(bool rented);
  ~Vehicle();
  
  void listVehicle();
  void addVehicle();
  void removeVehicle(int delData);
  void bookVehicle();
  void displayDetails(int regNo);
  void listCarsNotRented();
  void listFiveDoor();
  void listFordVansRented();
  };
  </code></pre>
  
  <p>For clarification the linked listed will contain a list of many objects that holds information about a vehicle, what I need to do is add a vehicle(object) to the list.</p>
  
  <p>The error occurs when trying to set the data within the node to the object I want.</p>