I need to use an array of 5 elements. Each element of the array is a structure with 2 fields: the name of the hotel and a singly linked list of attendees staying in that hotel.

Functions are:
CheckIn
CheckOut
Transfer
Count
Print
Quit

If someone could just show me how the classes are supposed to be built and how one function would be implemented, I can do the rest. I just can't figure out how it is supposed to be implement with the extra array element structure in the middle.

This is what I have so far

#ifndef DOUBLY_LINKED_LIST
#define DOUBLY_LINKED_LIST

enum IntHotel {
	Hershey,
	Milton,
	Sheraton,
	BestWestern,
	DaysInn
};

class SLLNode {
public:
	//pointer to next node
	SLLNode *next;
	//array to hold customer name
	char name[50];
	//constructor
	SLLNode(char n[], SLLNode *p = 0) {
		next = p; name = n
	}

};

class ArrayStruct {
	char hotelName [13];
	SLLNode *attendee;
};


class SLList {
public:
	//constructor
	SLList() {
		head = tail = 0;
	}
	//destructor
	~SLList();
	//actions
	void CheckIn();
	char* CheckOut();
	void transfer();
	int count();
	void print();
	void quit();


private:
	SLLStruct *head[5], *tail[5];
};

#endif

Much Thanks

>I just can't figure out how it is supposed to be implement
>with the extra array element structure in the middle.

It's just an array of linked lists:

struct Hotel {
  std::string name;
  LinkedList<Attendee> attendees;
};

Hotel hotels[5];
for (int i = 0; i < 5; i++) {
  std::cout<< hotels[i] <<'\n';

  Attendee::iterator it = hotels[i].attendees.begin();

  while (it != hotels[i].attendees.end()) {
    std::cout<< *it++ <<'\n';
  }
}

I added some code which is how I learned to implement the singly linked list. I just can't figure out how to work in the extra 5 element array structure ????

>I just can't figure out how it is supposed to be implement
>with the extra array element structure in the middle.

It's just an array of linked lists:

struct Hotel {
  std::string name;
  LinkedList<Attendee> attendees;
};

Hotel hotels[5];
for (int i = 0; i < 5; i++) {
  std::cout<< hotels[i] <<'\n';

  Attendee::iterator it = hotels[i].attendees.begin();

  while (it != hotels[i].attendees.end()) {
    std::cout<< *it++ <<'\n';
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.