Hi
I am studying for my C++ exam coming up & I have this practice question thats confusing me?
Given
enum months{Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
write a C++ function that takes currentMonth of type months as the parameter, and returns the next month. For example, nextMonth(Nov) should return Nov.
months nextMonth(months currentMonth)
{
//missing code
}
my attempt is (which doesn't work & I dont know why):
#include <iostream>
#include <cmath>
using namespace std;
enum months {jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec};
months nextMonth(months currentMonth);
int main()
{
months a = nov;
nextMonth(a);
cout << a << endl;
return 0;
}
months nextMonth(months currentMonth)
{
currentMonth = currentMonth + 1;
return currentMonth;
}