// DaysOfTheWeek.cpp : main project file.
#include <iostream>
#include <string>
usingnamespace std;
class DaysOfTheWeek
{
public:
// member funtions should be declared under the public section
void setDay(string);
// setDay(string) takes a string parameter and stores the value in the day attribute.
void printDay();
// printDay() prints the value of the day attribute on console output (cout).
string getDay(string&);
// retuns the value of the day attribute.
private:
// data members should be declared under private section
string day; // this is where the value of the day attribute is stored.
};
void DaysOfTheWeek::setDay(string day)
{
string Monday = "Mon";
string Tuesday = "Tues";
string Wednesday = "Wed";
string Thursday = "Thurs";
string Friday = "Fri";
string Saturday = "Sat";
string Sunday = "Sun";
}
void DaysOfTheWeek::printDay()
{
cout << "The value of the " << &DaysOfTheWeek::getDay << " object is " << &DaysOfTheWeek::setDay << endl;
}
string DaysOfTheWeek::getDay (string&)
{
return day;
}
int main()
{
DaysOfTheWeek monday;
DaysOfTheWeek tuesday;
string day = " ";
monday.setDay("Mon");
string day1 = monday.getDay(day);
monday.printDay();
tuesday.setDay("Tues");
string day2 = tuesday.getDay(day);
tuesday.printDay();
// set the values of the objects
// get the value for the Monday object and print it out
// print out the value of the Tuesday object
return 0;
}
I am getting "The value of the 1 object is 1" instead of Monday and Mon or Tuesday and Tues. I would appreciate any help.