hi I'm learning c++ from a book, know im on exception handling, but the book do not explain how to deal with exceptions when an error happens while creating an object, how i deal with this? heres my idea but dont works
//im attaking this problem fine or not? how i do it?
cout << "constructor called";
if(speed > 500)
//I need to catch the exception and call the destructor
cout << "at " << spd " you'r travelinig too fast";
cout << "Destructor called";
//error because 1500 is too fast, so destructor must be called
//here, or in other words object must be destroyed.
//code continues with object toyota already destroyed
//the books says !when u throw an exception from a constructor..
//the destructor is called" but this is not working to me"
thanks for any help , and please excuse my poor english