[haiku-development] Re: Review & Pull request for Workspaces app

On Mon, Dec 12, 2011 at 9:59 PM,  <devine-mlist@xxxxxxxxxxx> wrote:
> Counter-productive? I had better go read up on const then.

const has several different meanings depending on where/how it's used.
In the case where it trails a function, as is typical for a getter
(e.g. int GetProperty() const), it essentially tells the compiler to
treat "this" as read-only within that function, since it marks that
function as not being allowed to make any changes to the class in the
process. End result, if you try and do anything within such a function
that you shouldn't be, the compiler will flag an error and not let the
code compile. Same for function parameters, if marked as const, you
won't be able to modify them without the compiler warning you. In
general, it's good to mark things as const if you know you won't
(intentionally) be making changes to them since it allows the compiler
to help you catch errors that would otherwise go unnoticed until
runtime.

Regards,

Rene

Other related posts: