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
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.
// Gliptic
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.
// Gliptic
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.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.