Advertisement

Classes vs Functions

Started by January 25, 2000 11:52 PM
17 comments, last by Blah2 24 years, 8 months ago
Your iostream calls may go direct to assembly; however, the iostream functions do a lot more error checking than their stdio counterparts. The libraries are more robust, which leads to slightly slower programs.

Outside the libraries issue, if you don''t program C++ intelligently, you can really slow down the code. (by creating virtual functions for no reason, RTTI, etc.)
Most of the error checking is done at compile time. What kind of run time error checking to they do?

E:cb woof!

Edited by - dog135 on 2/1/00 3:14:27 PM
E:cb woof!
Advertisement
In the case of I/O functions, cin/cout does some memory management and buffer overflow checks that stdio functions don''t do.
Actually, I have heard of cases where just wrapping up functionality of important areas can produce enough overhead to slow down operations noticeably (happened to my firend''s engine), and thoug I''m not really a "me too" type person, but doesn''t Carmack use straight C. If someone who likes optimisation that much still uses it (as well as the makers of Jet and Genesis), maybe there is still some merit to it. Personally, I never learned straight C. I started using oop, and I will die ooping (maybe).

Dare To Think Outside The Box
_____________________________
|____________________________|
http://www.inversestudios.com
Write more poetry.http://www.Me-Zine.org
Quit arguing over cin/cout! That''s old school dos shiot! Shut up and use DirectX! (oh man, i don''t think i know what i''ve gotten myself into
cin/cout has nothing to do with DOS. It is only being used here as an example for discussion about the overhead associated with classes and wrapping C in OOP in general. The topic is in no way old and dated without relevance to today.

Kressilac
Derek Licciardi (Kressilac)Elysian Productions Inc.
Advertisement
I have began reading 'Tips of the Windows GAme Programming Gurus'. I am noticing so far that is using all C style functions and I am not seeing any classes or anything. If I were to decide to use classes rather than functions after I'm finished with the book, is their anything imparticular about classes in games that I should know (rather than learning the hard way )?

Edited by - felisandria on 2/2/00 12:49:31 PM
"you pseudo orgasmic bowl of cooked labia stew.. you bowl of fuzzy nutsack dribble! you pile of puffy ass ejaculate! DIE!! PIECE OF FUCKING SHIT!! uhh. you like eggdrop bots?"
I presume, derailer, you are reffering to LaMothe''s book.
If this is the case - when you get to about chapter 5 you will encounter C++ stuff, it starts talking about COM and DirectX which are both class based.
As for the general discussion, I would say that a well written C++ game will be quick and the code will be easy to look at and interperate.
But then that is possible with C too. However, it is nice to encapsulate all the methods relative to a particular area into a class.
For an example of fairly good C++ source look at Half-Life''s dll code. That wasn''t bad.

Take it easy,

-Mezz
Hey,
I was wondering about the statements that if you avoid virtual functions (and the other C++ specific features), you will not have to worry about that much of a difference between C and C++ as far a speed goes. I am working on a game engine that uses virtual functions and inheritance and was wondering how much overhead Virtual Functions produce?

Thanks

Brent Robinson
"What if this is as good as it gets?"
"The computer programmer is a creator of universes for which he alone is the lawgiver...No playwright, no stage director, no emperor, however powerful, has ever exercised such absolute athority to arrange a stage or a field of battle and to command such unswervingly dutiful actors or troops." - Joseph Weizenbaum-Brent Robinson

This topic is closed to new replies.

Advertisement