in my c++ course we have started classes. I created a class Date which has a default constructer
Code:
Date::date(int, int,int) that takes mm-dd-yyyy.
The private data is
Code:
int intmonth, day, year;
The function
Code:
string Date::toString() const
is to convert the int date to a string date. This is obviously simple, we only have to change the mm to a string, using an enumertion class
Code:
Month{January=1, ....}
Month month;
Now.. this functon must return a string. Therefore, the string must consist of
Code:
string Returnstring;
Returnstring = month(intmonth) + " " + day + "st/nd/rd/th" + ", " + year;
return Returnstring;
My problem: the concationation of this string. I cannot just output to the string, my teacher asked for the function to return a string. In the driver it has
Code:
cout << d1.toString();
I have read about the itoa function.. but i get the same prototype error as everyone else, and i have tried every hint online that have yeildd no results. I have heard of a function in class ostream in standard library? Does anyone know a good way to convert these integers to strings so i can do the concatination.
I use pico, and the sun compiler if it helps..
Thank you