I can guess what's wrong. I'm not sure what
return todayName = "dayname";
is going to return, but my guess is that it won't be what you want.
todayName
doesn't need to be a parameter to this function. It already returns a
string
, so just write
return "dayname";
in all those places. You don't even need the
break
statements that follow, and your
main
function will just do
cout << today(day) << endl;
If you actually wanted to update the
dayName
local variable in
main
, you would have to declare your
today
function as
void today(int day, string& todayName)
Note the
&
, which tells the code to update the argument that is passed into the function
instead of working on a copy which is lost when the function returns. With this approach,
main
would need to do
today(day, dayName);
cout << dayName << endl;