I had an Airplane class and this Airplane had a vector of Seat class named "m_seat". In the Constructor of my Airplane, I used the number of seats as the needed parameter to resize the m_seat vector size to the requested size of the user. This was my code:
class Seat;
class Airplane {
vector<Seat> m_seat;
public:
Airplane(int);
};
class Seat{
static int m_seatNumber;
public:
Seat() { m_seatNumber += 10; }
};
int Seat::m_seatNumber = 100;
Airplane::Airplane(int numberOfSeats) {
for (int i = 0; i<numberOfSeats; ++i) {
m_seat.push_back();
}
}
int main()
{
Airplane(80);
return 0;
}
But it gave this error.
std::vector<_Ty,_Aloc>::push_back no overload of function takes 0 arguments,
and if this was really the problem, I had no idea what should I have put in my push_back()? So I tried {}
m_seat.push_back({});
and It worked!
Now, I have another problem which is my main problem(SO rule: Ask only one question at a time!) that all seat numbers appear to be increased to the same number! I also used the "resize" member function of the vector, instead of that loop:
m_seat.resize(numberOfSeats);
But the problem (same increase in the number of the m_seatNumber) remains unsolved. Non-native English Speaker, Sorry.