Write your question here.
When I include the destructor I get a warning that says:
92 16 C:\Martin\Zola\dayType.cpp [Warning] deleting array '((dayType*)this)->dayType::days' [enabled by default]
Put the code you need help with here.
#ifndef DAY_TYPE_H
#define DAY_TYPE_H
#include <iostream>
#include <string>
#include <iomanip>
usingnamespace std;
/******* Class dayType Specification ********/
class dayType
{
private:
string days[7];
string currentDay;
int numDays;
public:
void setDay(string newDay);
void printDay() const;
int showDay(int& day);
int nextDay(int day);
int prevDay(int day) const;
int calcDay(int day, int numDays);
dayType()
{
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";
currentDay = days[0];
numDays = 0;
};
~dayType();
};
#endif
#include "dayType.h"
void dayType::setDay(string newDay)
{
currentDay = newDay;
}
void dayType::printDay() const
{
cout << "Day chosen is " << currentDay << endl;
}
int dayType::showDay(int& day)
{
return day;
}
int dayType::nextDay(int day)
{
day = day++;
if (day > 6)
day = day % 7;
switch (day)
{
case 0: cout << "The next day is Sunday";
break;
case 1: cout << "The next day is Monday";
break;
case 2: cout << "The next day is Tuesday";
break;
case 3: cout << "The next day is Wednesday";
break;
case 4: cout << "The next day is Thursday";
break;
case 5: cout << "The next day is Friday";
break;
case 6: cout << "The next day is Saturday";
break;
}
cout << endl;
return day;
}
int dayType::prevDay(int day) const
{
day = day--;
switch (day)
{
case -1: cout << "The previous day is Saturday.";
break;
case 0: cout << "The previous day is Saturday.";
break;
case 1: cout << "The previous day is Saturday.";
break;
case 2: cout << "The previous day is Saturday.";
break;
case 3: cout << "The previous day is Saturday.";
break;
case 4: cout << "The previous day is Saturday.";
break;
case 5: cout << "The previous day is Saturday.";
break;
default: cout << "The previous day is Saturday.";
}
cout << endl;
return day;
}
int dayType::calcDay(int addDays, int numDays)
{
addDays = addDays + numDays;
if (addDays > 6)
addDays = addDays % 7;
switch(addDays)
{
case 0: cout << "The calculated day is Sunday.";
break;
case 1: cout << "The calculated day is Monday.";
break;
case 2: cout << "The calculated day is Tuesday.";
break;
case 3: cout << "The calculated day is Wednesday.";
break;
case 4: cout << "The calculated day is Thursday.";
break;
case 5: cout << "The calculated day is Friday.";
break;
case 6: cout << "The calculated day is Saturday.";
break;
default: cout << "Not valid choice.";
}
cout << endl;
return addDays;
}
dayType::~dayType()
{
delete [] days;
}
#include <iostream>
#include <string>
#include "dayType.h"
usingnamespace std;
void showSelections();
int main()
{
dayType userDay;
int currentDay;
int addDays;
int test;
string day;
do
{
test = 0;
showSelections();
cin >> currentDay;
cout << endl;
if (currentDay = 0)
{
userDay.setDay("Sunday");
}
elseif (currentDay = 1)
{
userDay.setDay("Monday");
}
elseif (currentDay = 2)
{
userDay.setDay("Tuesday");
}
elseif (currentDay = 3)
{
userDay.setDay("Wednesday");
}
elseif (currentDay = 4)
{
userDay.setDay("Thursday");
}
elseif (currentDay = 5)
{
userDay.setDay("Friday");
}
elseif (currentDay = 6)
{
userDay.setDay("Saturday");
}
elseif (currentDay = 9)
{
cout << "Exiting...";
return 0;
}
else
{
cout << "Not a valid choice." << endl;
test = -37;
}
}
while (test < 0);
userDay.printDay();
cout << endl;
userDay.showDay(currentDay);
cout << endl;
userDay.nextDay(currentDay);
cout << endl;
userDay.prevDay(currentDay);
cout << endl;
cout << "Enter the number of days to add: " << endl;
cin >> addDays;
cout << endl;
userDay.calcDay(currentDay, addDays);
cout << endl;
cout << endl << endl;
system("pause");
return 0;
}
// Function to display weekday selections.
void showSelections()
{
cout << "*****Please enter a day of the week*****" << endl;
cout << "0 for Sunday" << endl;
cout << "1 for Monday" << endl;
cout << "2 for Tuesday" << endl;
cout << "3 for Wednesday" << endl;
cout << "4 for Thursday" << endl;
cout << "5 for Friday" << endl;
cout << "6 for Saturday" << endl;
cout << "9 to exit" << endl;
}