Structs vs Classes??

Started by
33 comments, last by RedGenie 21 years, 6 months ago
you know what!
someone should make a game programming book on when to use certain structures and functions (functions as in inline, inheritance, struct vs class, array vs pointer; not like void dropHealth ()

back to subject (please don''t erase above paragraph), if putting your function in the header file subjects them to being inline why don''t most programmer do that? well for the functions that need to be inline, not every class function they have.

so my question ultimately comes back to the original post (sorta) would code run quicker if you had (C)structs & functions or classes?

Beginner in Game Development?  Read here. And read here.

 

Advertisement
c++ struct and class info

i thought i'd mention something else too.

herb sutter commented that inline functions don't always give you the boost you imagine. in fact he says it can sometimes have detrimental effects. he says it's best to leave stuff like inlining until you can show that your application requires it and that it does improve the code.

madkeithv, you've got a tough job. thanks for all the time and effort you put. we all need to just take a few deep breaths.

i won't tell mum.

peace

edit: html

[edited by - petewood on October 22, 2002 9:24:26 AM]
Three rules to optimization:
1) Don''t optimize
2) Don''t optimize yet
3) Only optimize what a profiler specifically tells you to optimize

inlining has a huge drawback of tight physical coupling of implementation to clients. If a profiler tells you that a function is a bottleneck, try inlining it; usually, you shouldn''t do so until that point.
structs did not have the abilities of class in C. They were updated, updating them did not disturb any backwords compatibilty so there was no reason not to give structs OO capabilties.
quote:Original post by Stoffel
Three rules to optimization:
1) Don''t optimize
2) Don''t optimize yet
3) Only optimize what a profiler specifically tells you to optimize

Amen brother! Some of my code is SO slow, but it only gets called once per frame, so only anal programmers get bothered by it (as opposed to the end user). I always err on the side of readability. (that is, until rule 3 comes into play)

This topic is closed to new replies.

Advertisement