const operators

Sep 18, 2011 at 9:50am
Hi everybody,
Itried to search both this website and the internet regarding the following topic, but I haven't found anything...could you provide me some details regarding const operators? What are they? In what do they differ from non const, standard, classes operators? Is it like const operators are not alloweed to change class members values?

Many thanks
Sep 18, 2011 at 9:53am
That's basically it. Just like const methods, const operators can't modify the calling class. Certain operators are like this because they (likely) shouldn't be modifying the class; for example, operator+() for an integer class.
Sep 18, 2011 at 10:02am
...And what if I declare a const class? can I use a method defined as non const on a const class? And a const method on a non const class?
Sep 18, 2011 at 10:13am
Const class? You mean, const object? A const object can only execute methods declared as const, if that's what you mean.
Sep 18, 2011 at 4:33pm
Many thanks, and apologies for my mistake.
Topic archived. No new replies allowed.