Creating a Class for a main.cpp

!HELP PLEASE! can anyone guide me in the right direction with this program. i dont have thhe school book for the problem, but you can do it without it. this is the problem and the main.cpp that goes with it so you can check your Month.cpp for it... THANK YOU!!

Complete Programming Challenge 7 at the end of the chapter titled More About Classes. Modifications:
Don't need to overload << or >>
Don't need to overload postifx ++ or postfix --
Name the file Month.cpp
See the driver (in solution) to find the appropriate method names

this is what i have so far. they are in comments becuse thats what i think i need so far...
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
//#include <string>
 using namespace std;

 class Month
{
    private:
        //string name;
    public:
        //string getMonthName();
        //string Month();
};


this is the Main.cpp

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
#include <iostream>
#include "Month.cpp"
using namespace std;
 
void doOutput(string name, Month &m)
{
    cout << name << ": " << m.getMonthName() << " (" << m.getMonthNumber() << ")" << endl;
}
 
int main()
{
    cout << "Testing constructors" << endl;
    Month m1;
    Month m2(5);
    Month m3("December");
 
    doOutput("m1", m1);
    doOutput("m2", m2);
    doOutput("m3", m3);
 
    cout << "Testing setMonth methods" << endl;
    m1.setMonth(8);
    m2.setMonth("February");
    m3.setMonth(3);
 
    doOutput("m1", m1);
    doOutput("m2", m2);
    doOutput("m3", m3);
 
    cout << "Testing prefix ++" << endl;
    for (int x = 0; x < 12; x++)
    {
        ++m1;
        doOutput("m1", m1);
    }
    for (int x = 0; x < 12; x++)
    {
        ++m2;
        doOutput("m2", m2);
    }
    for (int x = 0; x < 12; x++)
    {
        ++m3;
        doOutput("m3", m3);
    }
 
}
Last edited on
Topic archived. No new replies allowed.