Hi guys the question I am attempting is
The elements stored in a Queue object can be of any type, including other objects.
Write an application to simulate a queue of people going to the cinema. The user may
input "j" to join the queue, "l" to leave the queue or "e" to end the program.
When a person joins the queue, their name and age is input and stored in a queue of
Person objects.
This evening, the cinema is showing a film rated as 15. When a person leaves the front
of the queue, their age is checked and one of the following messages is output:
<name> has left the queue and has entered the cinema
<name> has left the queue, but is too young to enter the cinema
Code:
//Task 2: Cinema
#include <iostream>
#include "Person.h"
#include <string>
#include <queue>
using namespace std;
int main()
{
queue <Person>* myQueue;
string e;
cout << "<j> Join queue, <i> Leave queue, <end> Exit program";
do
{
cout << "\n\nEnter a command: ";
getline(cin, e);
if (e == "j")
{
myQueue->push()
}
else if (e == "i")
{
}
else
{
cout << "Incorrect entry. Please try again!\n";
}
} while (e != "end");
system("PAUSE");
return 0;
}
My problem is that on line 20 I cannot figure out how to access the queue from the person class and access the person methods
Code:
myQueue->push(/*Access Class*/)
//Person c.pp
Code:
#include "Person.h"
Person::Person()
{
}
Person::~Person()
{
}
void Person::setName(string n)
{
name = n;
}
string Person::GetName()
{
return name;
}
void Person::setAge(int a)
{
age = a;
}
int Person::GetAge()
{
return age;
}