I have written this code and it compiles and works just fine but I would like to put the string day[7]; as private since the days of the week will never change and I am required to have at least one private member in my code. When I simply move it the code compiles but errors out like crazy! Can anyone help me? I hesitate to post my whole code as I would like my work to remain my work so here is the first part without the main function(even though what I am posting is the most important part).
#include<iostream>
#include<string>
using namespace std;
class dayOfTheWeek
{
public:
string day[7];
dayOfTheWeek();//constructor
~dayOfTheWeek();//destructor
int dayNum;
int tempDay;
void getDay(int &day);
void setDay(int _day);
void printDay();
void plusOneDay();
void minusOneDay();
void addDays(int _changeDay);
private:
};
dayOfTheWeek::dayOfTheWeek()
{
dayNum=0;
day[0]="Sunday";
day[1]="Monday";
day[2]="Tuesday";
day[3]="Wednesday";
day[4]="Thursday";
day[5]="Friday";
day[6]="Saturday";
};
dayOfTheWeek::~dayOfTheWeek()
{
}
void dayOfTheWeek::printDay()
{
cout << "Today is: " << day[dayNum] << endl << endl;
};
void dayOfTheWeek::setDay(int _day)
{
dayNum=_day;
};
void dayOfTheWeek::getDay(int &day)
{
day=dayNum;
};
void dayOfTheWeek::plusOneDay()
{
dayNum++;
};
void dayOfTheWeek::minusOneDay()
{
dayNum--;
};
void dayOfTheWeek::addDays(int _changeDay)
{
tempDay =(dayNum + _changeDay);
dayNum =(tempDay%7);
};