class Airplane{
public:
string airplaneName;
string captainName;
string copilotName;
int passangerNumber;
bool captain;
bool copilot;
};
class Fleet{
public:
string fleetName;
Airplane airplaneFleet;
};
So I have to add all elements from Airplane (actually a couple of airplanes) to one fleet, how do I do that. I've tried different codes but I'not even close, if you have some solution please explain, thanks!
Based on the question, you can either have an array of some defined size, or a vector
to which you can add elements at runtime.
Airplane airplanesInFleet[10]; // Fixed - 10 airplans
std::vector<Airplane> airplanesInFleet; // Dynamic - use 'push_back' to add airplane
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.