I now that a non const member function on a non const object. And const member function on a const object. But can a const object parameter use member function that is not const?....
Tyree
Printable View
I now that a non const member function on a non const object. And const member function on a const object. But can a const object parameter use member function that is not const?....
Tyree
What are you talking about? There aren't any restrictions for const-types except that they cannot be changed.
You can pass a non-const object to a function taking const argument, it just won't be modified. You, however, cannot pass a const object to a non-const function.
...if you don't cast it.
And if you ever cast a const to a non-const your will go directly to programmers hell !
>But can a const object parameter use member function that is not const?....
No. Thats the reason behind it all. A const anything isn't changeable. So non-const member functions ( those functions changing the inner state of the object ) cannot be called.
*wavesPitchFork* Never cast a const to non-const.