Computer Chess Club Archives




Subject: Re: C and C++ --- NPS

Author: Matt Taylor

Date: 19:23:28 12/25/02

Go up one level in this thread

On December 25, 2002 at 15:56:19, Dave Gomboc wrote:

>On December 25, 2002 at 15:38:19, Matt Taylor wrote:
>>>Overloading costs nothing, it's a compile time construct and is resolved at
>>>compile/link time.
>>>Inheritance costs nothing, it too is a compile/link time issue.
>>>You know nothing about C++, do you? I didn't think so.
>>Overloading costs an indirect function call. I'm not sure if you can apply const
>>to a class like you can apply final to one in Java, but unless the compiler
>>knows the class can't be inherited from, it has to make the operator an indirect
>>function call.
>Calling a class const in C++ means something else, but a C++ compiler can (and
>some do) figure out which classes are at the bottom of the inheritance hierarchy
>at compile-time.  (Unlike with Java, this isn't mutable at run-time.)

Ah, sorry, I was somehow thinking of Java where everything can be overloaded
unless you say otherwise. Still, polymorphism still does not come for free.

Another thing which C++ cannot do involves elimination of branches. If you have
a switch/case with a few cases and a small number of computations, the best
thing to do is compute them all and conditionally select the result (does not
require branching).


This page took 0.03 seconds to execute

Last modified: Thu, 07 Jul 11 08:48:38 -0700

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