I have a function where I want to add pointers into a vector.
#include "Car.hpp"
using namespace std;
bool CarManagementSystem::addCar(Car::CarType new_car_type) {
if (Car::CarType(new_car_type) == (Invalid)) {
return false;
}
else{
new Car::CarType(new_car_type);
carVector.push_back(Car::CarType(new_car_type));
return true;
}
}
The push_back
command is giving me a lot of grief as in to what form I want the constraints to be in. I want to be able to use this function to create different types of my object Car, however am unsure how to do this.
The car class is purely virtual base class for all my different types of cars.
#include "Car.hpp"
Car::~Car() {
}
Car::CarType Car::type() const {
return AT_INVALID;
}
class CarSystem {
private:
double Balance;
double CarCost;
std::vector<Car*> carVector;
...