Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Can I teoricaly do the same program and with same speed in C and C++?

Author: Eugene Nalimov

Date: 19:44:49 08/30/99

Go up one level in this thread


On August 30, 1999 at 22:36:00, Andrew Dados wrote:

>On August 30, 1999 at 22:19:35, Eugene Nalimov wrote:
>
>>Yes, of course. You always can compile your C program by C++ compiler and call
>>it C++ program.
>>
>>Speaking seriuosly, as long as you don't use virtual methods instead of usual
>>functions, all that class stuff is just syntactic difference. Generated code
>>will be exactly the same as for C program with structures and global functions.
>>And of course you can use C++ virtual methods instead of function pointers in C
>>without performance loss.
>>
>>Eugene
>
>  I would think that looking up virtual method table can not be as fast as
>passing/calling function pointer...
>-Andrew-

Theoretically it's slower, you are right, but in practice I doubt you'll notice
one or two extra instructions. Please note that there is no search at runtime,
as compiler knows offset of method in vtable at compile time.

Eugene



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.