*Just started learning classes/objects*
I am having trouble with my private bool arrays in my class flight.
Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
class Flight
{
private:
bool f_seats[10];
bool e_seats[10];
public:
Flight();
void f_reserve(int &s);
void e_reserve(int &s);
};
int main()
{
Flight greyhound;
int chose = 0;
cout << "Please choose section of preference: Press.. " << endl;
cout << "1) First Class " << endl;
cout << "2) Economy Class " << endl;
cin >> chose;
greyhound.f_reserve(chose);
system("Pause");
return 0;
}
Flight::Flight()
{
bool f_seats[10] = {false, false, false, false, false, false, false, false, false, false};
bool e_seats[10] = {false, false, false, false, false, false, false, false, false, false};
}
void Flight::f_reserve(int &s)
{
cout << "Seat: " << f_seats[0] << endl;
}
I am running a test thus far, but I'm not getting the result I want. In
Code:
void Flight::f_reserve(int &s)
{
cout << "Seat: " << f_seats[0] << endl;
}
The output should be 0, since the first element in the array is false. However, the output that I am getting is 204. I am confused as to how that is possible since f_seats[10] is a member function of that class. Should I place the bool f_seats in the Flight constructor parameter list? such as Flight::Flight(bool f_seat[10]).
or am I doing something else wrong.
Feel free to ask questions for clarification.