Hello, I am a C++ newbie. I am working on a project to create a phone book. The entries of the phone book have to be set up as objects of a class. Each object will have three attributes - name, number, and a note. I am having a really hard time understanding the nature of a class in C++. The attached code is how I have set up my class and includes comments to explain what I hope to accomplish in each line of code. I am getting error messages and don't understand why. Can you help?
Code:
string x, y, z; // Global variables
// Class
class contactList
{
public:
contactList(); //Establish a generic object.
contactList(string name[100], string number[100], string note[100]);
string name[i] = ""; // Automatically set up the name field to empty.
string number[i] = ""; // Same for number field
string note[i] = ""; // Same for note field - Note is an option field, so some
// entries may not have note data.
// These functions will allow the main program to change the variables
void setName(string x) // When called, this function will take a string x that is
{ // provided in one of the functions and assign to name field
name[i] = x; // of the current entry.
}
void setNumber(string y) // Same as above, but for the number field.
{
number[i] = y;
}
void setNote(string z) // Same as above, but for the note field.
{
note[i] = z;
}
// These functions will allow us to retrieve the name of a variable
string getName() // When called, this function will retrieve the name of the
{ // current entry for display.
return name[i];
}
string getNumber() // Same as above, but for the number field.
{
return number[i];
}
string getNote() // Same as above, but for the note field.
{
return note[i];
}
private: //Placing the variables here will make them more secure.
string name[], number[], note[];
};