Skip to main content
GameDev.net gamedev.net
🔒 Locked

c and c++

Started by a38750 Oct 24, 2000 at 1:26 PM 4 replies 250+ views
Original Post
a38750
a38750
I know that C is faster then C++, but does it have to be compiled in C, or is it just the lack of object orientation and stuff that makes it faster? I don''t want to have to use manky /* */ comments you see. thanks Frank
Martee
Martee
About the comments: Most modern compilers allow you to use C++ style comments, //, even if your program is in C

Now as for the C vs. C++...C is a subset of C++, which means that, in theory, any C program will compile and run fine as a C++ program. I suppose it doesn''t happen exactly like that in real life, though...



==================
/* todo: insert cool sig */
Martee
Magnum Games.NET
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
ImmaGNUman
ImmaGNUman
Hmm....

int main()
{
main();

return 0;
}

Nope, that shouldn''t compile on any standard C++ compiler, but will on a C compiler. Anyway, as the creator of Duff''s device said... "I don''t know whether it is an argument for or against."

-----------------------------

A wise man once said "A person with half a clue is more dangerous than a person with or without one."

The Micro$haft BSOD T-Shirt
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
djsteffey
djsteffey
i dont understand how you can say that c is faster then c++, i would think that they are both the same speed. You might be tempted to say that c++ classes are slower then using a c struct or something like that but it isnt true. It is true that when you call a member funciton of a class a pointer to the instance of that class is also passed (hiddenly), but if you were just going to use a c struct then you would have to pass in a pointer to the struct as one of the arguments......so i really dont see the difference other then style


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

JD
JD
Using c++ polymorphism can slow it down a bit. You''re indirectly calling a function in the virtual table. But generaly c++ is as fast if not faster(better compiler optimizations) than c. Nowdays there are few pure c compilers and I think compiler writers might have found better ways to optimize the remaining compilers which in majority are c++ ones. Also the extra type checking of c++ at compile time might slow it down a bit but not during the runtime.
Quantum
Quantum
from what i''ve seen, MSVC with optimizations will generate at least as fast, if not faster C++(classes & member functions) than C(structs and normal functions) code.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.