You defined setNumber
const, Which means this function will not change any member of the class. Just remove const
from function implementation.
class ho1
{
int number;
public:
ho1();
void setNumber(int x)
{
number = x;
};
};
solved How fixed function access to the class data member?