creating class instance from a file
Keeping in mind that I'm a beginning programmer, I have a question about a program I've been writing for practice, and to hopefully learn some new insights on programming technique.
Please also remember that these are concepts I've come up with entirely on my own, and if they seem a little weak, please don't hesitate to suggest a better way of doing something.
It's going to be a console app that uses two classes: list, and contact.
Each list will have a name, and a vector of contacts. The class contact would consist of multiple strings to store the first and last names, e-mail, and phone number, etc.. I want to be able to perform various operations on the list, like sorting, editing or deleteing contacts on the list.
To perform an operation on a list however, you must first load it. This would consist of creating an instance of the class list, and it's contacts, depending on what the program reads from a file which would contain the list, and it's contacts.
I was wondering how on earth I could 'load' a list. Reading in the file probably wouldn't be much of a problem once I get rolling, but I'm a little confused on how to refer to the loaded list. Should I create a global pointer to a list that starts out blank? ('Blank' perhaps represented as a boolean variable so that the program will be able to tell if you loaded a list, instead of trying to preform operations on a list that hasn't yet been created?)
Another question I had (and I'm pretty sure it has to do with dynamic memory allocation) was:
How can you create a variable, but let the user choose the identifier?
If that doesn't make any sense to you, then it probably doesn't have an answer.
Thanks for your time.