By background, I am a database person. I am trying really hard to wrap my head around C++ for a class I am taking. The following is an assignment that I just received. I don't want the answers but I would like if possible, to start a discussion. My class is online and I feel like I am missing the discussion that is necessary for me to get it! Again, I'm not asking for you to do it for me... I just want to have intelligent discussion. To me it looks like I need a fairly deep array. I keep imagining a table like one of my databases. I keep coming up with lines but they look like something out of a simplified visual basic code.

Create a program that is based on objects.
The main functions should include storing and retrieving information about people.
Part 1
Create an object of type Person. The data attributes should be private.
Each attribute should have a setter and a getter.
The attributes include: first name, last name, date of birth, email address, phone number.
Part 2
Create an event-driven program that contains the following options:
Create a record (initializes a new object and add it to the list of contacts in the array)
Add/Modify first name
Add/Modify last name
Add/Modify phone number
Add/Modify email address
Add/Modify date of birth
Print record
If the user chooses to add any information or to print the record before the person has been created the
system should notify the user about the fact that a record does not exist yet.
Part 3
If a person's information is already set you should ask the user if they want to overwrite the old data.
Part 4
When you print the person's record you should display the information in the following manner:
Judy Miller (01/01/01)
If any information is not available let the user know by printing dashes in place of the missing data.
The data is stored in the file “contacts.txt”. Comment each relevant part of code stating its purpose.

Let's start simple. Do you understand Part 1 of the assignment? Can you code that much up and see if it will compile?
Then can you use create an instance of the class, use the setters to populate the instance, and the getters to verify the values? Third, add a print() method to your class which addresses part 4 (and the last item in part 2), and verify that it correctly prints the instance values. Then we'll go from there!

Or if this is still a mystery, we can back up. It's probably best not to try to map your understanding of C++ onto the world of databases. Instead think of a class-instance as an abstraction of a real-world object, as much as a row in a database table might represent the same object. The class itself is the genotype (to borrow from biology): a Person class specifies what info is necessary to represent a specific person, and the methods on that person (what a person is capable of doing or telling you about itself). An instance of person specifies the specific values of the info that differentiate that person from all the others.

This article has been dead for over six months. Start a new discussion instead.