Computer Chess Club Archives


Search

Terms

Messages

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

Author: Matt Taylor

Date: 12:38:19 12/25/02

Go up one level in this thread


>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.

>>I had to chose between writing my GUI functionality (database and such)
>>in C or C++ before i started. Initially i wanted to start it in C++
>>but in the end i figured out that speed for a chess database is not
>>unimportant so i wrote it in C.
>
>If there was a speed difference for that kind of application, it just goes to
>show how bad you are at C++ programming, or at programming in general.

C code in C++ is the same speed, but using C++ constructs can be slower.
Multiple inheritance, polymorphism, etc.

>>But i could of course have done it in C++ as well. In fact if i change
>>the extension of the code from *.c to *.cpp then it pretty quickly
>>is c++ code already, the nearly same code being both C and C++. Says
>>enough to me about speed differences.
>
>C++ has nothing to do with extensions, Vincent...

Most compilers I have worked with (Borland, Symantec, Microsoft) decide whether
to compile C++ or C based on file extension, though you can always pass a flag
and force C++ rules. I believe GNU C also does this, but I have ignored the
commandline options except for optimization flags.

-Matt



This page took 0.01 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.