Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C++ Programming Q: are const and define efficiency the same

Author: Bo Persson

Date: 16:20:42 01/17/04

Go up one level in this thread


On January 17, 2004 at 17:22:34, Russell Reagan wrote:

>On January 17, 2004 at 16:59:29, Robert Hyatt wrote:
>
>>The compiler should do that automatically.  That is a common optimization
>>to avoid doing extra work.
>
>Okay, so the compiler will do this regardless of whether you declare the
>intermediate variable const or not. Is that right?

Yes, the compiler will know that it is not changed anyway and optimize the same.

The const does help the programmer though, as it shows the intention so the
compiler can warn you if you are wrong...


Bo Persson




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.