std::vector is like most usable component of Java: ArrayList. It's an "array", which changes its size dynamically.
Use it, when it comes to containing a collection of elements.
#include <vector> std::vector<int> v; v.push_back(1); v.push_back(3); v.push_back(3); v.push_back(7); // like an array for(size_t i = 0; i < v.size(); ++i) std::cout << v[i] << std::endl; // using iterator for (std::vector<int>::iterator it = v.begin(); it != v.end(); ++it) std::cout << *it << std::endl;
Create classes VehiclePart and Vehicle. Vehicle contains many parts, which can we modify any time we want.
Car is a vehicle, which moves across lands.
It should have a method: "drive".
If you want to drive a car, the car should contain a driver.
Boat is a vehicle, which natural environment is water.
Boat has a method "sail".
Each boat has a harpoon.
Amphibian is a boat and a car.
It can move, way depends on calling a method from base calss according to a type of terrain.