Trienco, on 28 February 2012 - 01:22 PM, said:
And thanks to the new standard the discussion is (finally) obsolete. Get a recent enough compiler and use nullptr. No more ambiguity, no more macros.
true.. and the stl made also the code quoted from the book totally archaic and error prone long time ago.
All is needed is a:
vector< Car*> cars;
member in Garage.. and the addCar function would be as simple as cars.push_back( new Car() );
In C++11 a bit uglier but with the plus of automatic deletion:
vector< shared_ptr<Car> > cars;
cars.push_back( make_shared<Car>() );


















