Functions continue to give me problems, I am unable to see the issues any help would be appreciated.
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(28) : error C2511: 'void DayOfTheWeek::printDay(void) const' : overloaded member function not found in 'DayOfTheWeek'
1> c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(11) : see declaration of 'DayOfTheWeek'
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(56) : error C2440: '=' : cannot convert from 'std::string' to 'int'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(57) : error C2562: 'DayOfTheWeek::setDay' : 'void' function returning a value
1> c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(14) : see declaration of 'DayOfTheWeek::setDay'
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(63) : error C2511: 'std::string DayOfTheWeek::getDay(void) const' : overloaded member function not found in 'DayOfTheWeek'
1> c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(11) : see declaration of 'DayOfTheWeek'
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(68) : error C2511: 'std::string DayOfTheWeek::plusOneDay(int)' : overloaded member function not found in 'DayOfTheWeek'
1> c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(11) : see declaration of 'DayOfTheWeek'
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(74) : error C2511: 'std::string DayOfTheWeek::minusOneDay(int)' : overloaded member function not found in 'DayOfTheWeek'
1> c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(11) : see declaration of 'DayOfTheWeek'
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(80) : error C2511: 'std::string DayOfTheWeek::addDays(int)' : overloaded member function not found in 'DayOfTheWeek'
1> c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(11) : see declaration of 'DayOfTheWeek'
1>c:\users\ben\documents\visual studio 2008\projects\week2lab_benjamin_horne\week2lab_benjamin_horne\dayoftheweek.cpp(117) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#include <iostream>
#include <string>
using namespace std;
class DayOfTheWeek
{
public:
void setDay(string);
void printDay();
string getDay();
string plusOneDay();
string minusOneDay();
string addDays();
private:
int day;
int toNumber(string);
string toName(int);
};
void DayOfTheWeek::printDay()const
{
cout << "The value of the " << day << " object is ";
if (day == "Monday")
cout << "Mon" << endl;
if (day == "Tuesday")
cout << "Tues" << endl;
if (day == "Wednesday")
cout << "Wed" << endl;
if (day == "Thursday")
cout << "Thur" << endl;
if (day == "Friday")
cout << "Fri" << endl;
if (day == "Saturday")
cout << "Sat" << endl;
if (day == "Sunday")
cout << "Sun" << endl;
}
void DayOfTheWeek::setDay(string d)
{
day = d;
return toNumber(d);
}
string DayOfTheWeek::getDay()const
{
return day;
}
string DayOfTheWeek::plusOneDay(int add)
{
int add = day + 1;
return toName(add);
}
string DayOfTheWeek::minusOneDay(int minus)
{
int minus = day - 1;
return toName(minus)
}
string DayOfTheWeek::addDays(int incr)
{
int idx = day + incr;
if (idx < 0) idx += 7;
return toName(idx);
}
int DayOfTheWeek::toNumber(string name)
{
if (name == "Monday") return 0;
if (name == "Tuesday") return 1;
if (name == "Wedensday") return 2;
if (name == "Thursday") return 3;
if (name == "Friday") return 4;
if (name == "Saturday") return 5;
if (name == "Sunday") return 6;
}
string DayOfTheWeek::toName(int idx)
{
idx = idx % 7;
switch (idx)
{
case 0: return "Monday"; break;
case 1: return "Tuesday"; break;
case 2: return "Wednesday"; break;
case 3: return "Thursday"; break;
case 4: return "Friday"; break;
case 5: return "Saturday"; break;
case 6: return "Sunday"; break;
}
}
int main()
{
DayOfTheWeek monday;
monday.setDay("Monday");
cout << "The value of the Monday object is " << monday.printDay()<< endl;
return 0;
}
|