int & geta(void) const { return *a; }
int & getb(void) const { return b; }
In a const function, each data element becomes const in such a way that it cannot be changed . intbecomes const int, int *becomes int * const, etc.
Since the type ain your first function becomes int * const, not const int *, therefore, you can change the data (which can be changed):
m.geta() = 5; //works, as the data is modifiable
The difference between: const int*and int * const.
const int* , const, , , const.int * const , const, , , const.
const int &, b const int. int &, (. this), , main(), . :
const int & getb(void) const { return b; }
!.