Hi! I'm supposed to create a class named Appointment. I have given the private member functions, All data should be private, and reached by get- and set-functions.
The class should have appropriate constructors. I have to decide what constructors are needed / helpful.
What kind of constructors do I need?
Is my mutator/accessor functions correct?
My code:
class Appointment
{
public:
void set(string newTime); //makes it possible to change the time
void set(string newPlace); //makes it possible to change the place
void set(string newHeader); //makes it possible to change the header
void set(string newDescription); //makes it possible to change the description
string getTime(); // returns the time
string getPlace(); //returns the place
string getHeader(); //returns the header
string getDescription(); //returns the description
private:
string time;
string place;
string header; //quick summary of the appointment
string description; //longer description
};
void set(string newTime); //makes it possible to change the time
void set(string newPlace); //makes it possible to change the place
void set(string newHeader); //makes it possible to change the header
void set(string newDescription); //makes it possible to change the description
Will NOT work. You cannot overload a function simply based on the name of parameter (the compiler doesn't care what the name is if you are prototyping it)
You will need to make functions like:
1 2 3 4
void setTime(string newTime); //makes it possible to change the time
void setnewPlace (string newPlace); //makes it possible to change the place
void setHeader(string newHeader); //makes it possible to change the header
void setDescription(string newDescription); //makes it possible to change the description