A shuttle van picks up passengers and drives them to a destination, where they all leave the van. Keep a count of the boarding
A shuttle van picks up passengers and drives them to a destination, where they all leave the van. Keep a count of the boarding passengers, but don't allow boarding if the van is full. First show the constructor, then the functions. (For simplicity, the drive function doesn't update the location.) Unused private: count++; Van:: Van(int max_passengers) { Van(int max_passengers); count = 0; void Van::drive() { int get_count() const; public: capacity = max_passengers; } if (count capacity) { void Van::board() { } count = 0; } int capacity; void drive(); int count; } void board(); main.cpp #include using namespace std; class Van { }; int Van::get_count() const { return count; } int main() { Load default template... Van new_van(5); cout < < "Number of Passengers: " < < endl; cout < < new_van.get_count() < < endl; for (int i = 0; i < 2; i++) { new_van.board(); cout < < new_van.get_count() < < endl; } new_van.drive(); cout < < new_van.get_count(); - cout < < " Drop off at destination" < < endl; for (int i = 0; i < 6; i++) { } new_van.board(); cout < < new_van.get_count() < < endl; new_van.drive(); cout < < new_van.get_count(); } cout < < " - Drop off at destination" < < endl; return 0;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started