IMH knowledge, C code will add some 'overhead' for function calls, etc. that you could skip by writing your code in pure ASM (provided that you code specific pushes/pops in your code and no pusha/popa as i used to do to avoid misordering of such operations)
On the other side, a good C compiler (gcc in mind) is able to produce in a few ms machine code that pairs better on pentium CPUs than what human beings can do in an evening ...
Same compiler can (if enough optimizations are chosen) automatically inline some functions, use registers for frequent variables, etc.
For C++ vs C, i didn't see major differences in generated code if you use classes with static (err. i mean non-virtual) methods. However, things like multiple inheritance, run-time typing informations (dynamic casting) or exceptions handling are usually implemented behind the scene with heavy computationnal power (such as multi-pass unrolling stacks, etc.)
If you have to choose between
[table][tr][td]
{
res_hndl = new resource();
hazardous_operation();
/* normal processing goes on */
}
/* exceptions as well as normal processing
will call the res_hndl dtor at the end of
the block, so resources are freed at the
end of hazardous_operation() even if
this fails and ends with an exception throw
*/
[/td][td]
{
int errcode=FAIL;
void *handler = get_resource();
if (errcode = hazardous_operations()) goto fail;
/* normal processing continues */
release_resource(handler);
return <good value>;
fail:
if (handler) release_resource(handler);
return <error code>;
}
[/td][/tr][/table]
The rightmost(and not leftmost as i mistyped earlier
) code will be from far faster. There can be many other ways to implement it, but i used to have a "goto fail" trick because you can centralize error processing at one place of your function (this is philosophical choice from an old ASM-coder and C prophets would call me heretic if they knew it