Logical const

so so at so.do
Mon Nov 29 07:27:48 PST 2010


> I am technically worse off, just not from the compilers point of view.
>
> I see your point about C++ const being a convention, but that doesn't  
> change the fact that it is still very useful, even if it useless for the  
> compiler. If I give some const object to a function:
>
> void render(const GameObject&);
>
> GameObject obj;
> render(obj);
>
> I can be sure that my object will come back unmodified. That it is the  
> primary purpose of const. Like you said, it allows you to reason about  
> your programs.
>
> Yes, GameObject could be unreasonably mutilated by careless use of  
> mutable, but in practice that simply doesn't happen.

That is wrong, you can't be sure that will come back unmodified in C++.

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list