I have a class set up, Vehicles. I have the constructor and variables set up correctly, and I can properly create an object of this class through code, such as:
Vehicle minivan;
It naturally follows that I can create multiple objects of this class in code, such as:
Vehicle minivan;
Vehicle truck;
Vehicle car;
However, what I cannot figure out is how to allow the user to determine how many objects he wants to create without specifying a large number of them in code and hoping he doesn't want to create more than that number.
My program allows a user to create a vehicle, specifying the name and various features. After creation, the user is brought back to the main menu and has the option of creating another vehicle in the same manner. The user is able to do this as many times as he fancies, but I cannot work out a way to create a new object on the fly without having it predefined in the code, such as:
I know the following code isn't even close to legit, but I'm looking for a solution that would function in this manner. Please ignore the fact that this isn't even close to real code, and just focus on the intention of what I have here:
Is this impossible? Or perhaps I simply haven't gotten far enough along in my self-teachings to reach a specific function that allows me to accomplish this?
Or you could learn about pointers and dynamic memory-it'll help you even in cases where you can't use the STL. (I.E. a class at school, or something with an extremely small amount of memory)