-
March 20th, 2009, 06:38 AM
#1
Creating objects with functions.
Hi,
I am making a console program which has a menu, for example:
Enter your choice and press Enter:
1: Add a new vehicle
2: Delete a vehicle
3: Search for a vehicle
I then have a switch in main, if the user selects 1, I call a function and create a new object.
I'm wondering, once the object is created within the function, how best to enter in into a vector.
Can/should I return the object back to main, and then push it onto the vector? Or can I push it onto the vector straight from within the function?
Also I have a few different classes in the program, types of cars and motorbikes.
I'm new to vectors (this program will have to use a doubly linkedlist eventually, but thought I'm using vectors first to just get the program working. I hope it wont be an issue converting the container types, perhaps it will just mean adding another pointer to each vector?
But should I have one vector for each type of class? I cannot use one sigle vector for all the different class types, can I? The different classes hold differently named member variables.
Sorry for the 20 questions.
Thank you very much!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|