By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,191 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,191 IT Pros & Developers. It's quick & easy.

const objects ->const member functions?

P: n/a
I am just curious: if you declare an object constant - can it call NOT
constant member functions of the class or only constant ones?
are there generic rules for such objects?
THANKs

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
puzzlecracker wrote:
I am just curious: if you declare an object constant - can it call NOT
constant member functions of the class or only constant ones?
I believe only const member functions may be called on a const object.

are there generic rules for such objects?


const objects are meant to be non-changing. A function that will not
alter the instance it is operating on should be labeled as const to
represent this fact. Member functions that do change the internals of
their instances must not be used on an object that is not supposed to
change.

It is pretty straight forward if you keep in mind what 'const' means.
It means 'constant'.

Hope that helps.
Jul 23 '05 #2

P: n/a
"puzzlecracker" <ir*********@gmail.com> wrote in message
I am just curious: if you declare an object constant - can it call NOT
constant member functions of the class or only constant ones?
It can only call constant ones.
are there generic rules for such objects?


What do you mean?
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.