• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

linked list

/********************************reservation class******************/

class Reservation {      //private members
      Date      compare;
      Date      res_made;
      Date      pick_up;
      Date      due_back;
      int            con_months;
      enum      truck_type {Toyota, Nissan, Acura} trucks;
      //char*      truck_des[];
public:                  //public members/funcions
      Reservation      *next;
      void res_date (Date);
      void set_con (int);
      void set_dueback (Date);
      void print (void);
      void res_compare(void);
      //Date res_date (Date);

/*****************************future.h file******************************/

#include "res_header.hpp"

class future
            Reservation* list;
            Reservation* leader;
            Reservation* follower;
            Reservation* tail;
            int count;
            void print(){cout<<"testing future"<<endl;}

/*************************************future.cpp file******************/
#include "res_header.hpp"
#include "future.hpp"


      void create_list(Reservation *temp, Reservation temp_reserve_data)
            temp=new Reservation;

                  while(tail->    // ********here when I write tail-> the list is not
//getting displayed. How to write a linked list. Could you please tell me how to write a linked list in a c++. I know it in c. I am  not able to do it in c++. */
                  /*if (temp->compare ==1)

1 Solution
rmvprasadAuthor Commented:
Here future and reservation are classes. so I want to know how to do linked list of classes.
Use STL list class for this

The STL list class is a template class of sequence containers that maintain their elements in a linear arrangement and allow efficient insertions and deletions at any location within the sequence. The sequence is stored as a bidirectional linked list of elements, each containing a member of some type Type.

template <
   class Type,
   class Allocator=allocator<Type>
class list
The element data type to be stored in the list. (can be future or reservation class types)
The type that represents the stored allocator object that encapsulates details about the list's allocation and deallocation of memory. This argument is optional, and the default value is allocator<Type>.

You can refer to the code for insert at
Also you can refer to

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now