I am working with a dateType class and need to make a function to show next day and the previous day. I have my function set using const keyword so that it can't be changed by users, but now I can't increase my day. help???

int dateType::nextDay() const
{
getDay();
dDay++;
return dDay;
}
int dateType::previousDay() const
{
getDay();
dDay--;
return dDay;
}

Recommended Answers

All 2 Replies

Please use code tags to post your code. Enclose your code in code tags.
Also post your entire code so that we can be in a state of answering your questions, dont post half baked snippets.

Functions can't be edited by users anyway. When a function is const, it means that function can't change anything outside of it, which in your case is dDay. Get rid of the const and it'll work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.