Thread
:
Help with code please!
View Single Post
priyatendulkar
Go4Expert Member
27Jun2011,11:42
Hi,
Your code crashes becoz of line ..
car * car_array = new car[(car_num - 1)];
Say for example..
car_num =4.
In your case memory will be allocated only for 3 objects.Hence the program crashes.
Modify it as
car * car_array = new car[(car_num )];