I was given the main and told to create a program in response to the main using 3 classes. An amusement park class, a rider class, and a ride class. I want to add a rider to a vector of rides and store that vector in a vector of amusement parks. What am I doing wrong? How can I fix this?
#include <iostream>
#include <string>
using namespace std;
class Rider
{
string name;
int height;
public:
Rider(string name, int height)
{
this->name=name;
this->height=height;
}
Rider(int height)
{
this->height=height;
}
};
class Ride
{
public:
vector <Rider> all_riders;
};
class Amusement_park
{
vector <Ride> all_rides;
public:
Amusement_park(int numRides)
{
all_rides[numRides];
}
vector <Rider> get_ride(int whichRide)
{
vector <Ride> the_ride= all_rides[whichRide];
return the_ride;
}
void add_line(class Rider)
{
the_ride.pushback(Rider);
}
};
int main()
{
Rider r1("Yaris",45); //name, height in inches
Rider r2(49); //height in inches
Amusement_park a1(3); //3 is the number of rides in the park
a1.get_ride(1).add_line(r1); //add a rider to the line of a ride
Amusement_park a2(2); //2 is the number of rides in the park
a2.get_ride(1).add_line(r2); //add a rider to the line of a ride
return 0;
}