Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Sinner_Zero

MY GOD, Does C++ suck?

This topic is 6508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ummmm.....I''ve been told that structs are faster (and thus in the end superior) to classes, is this true? Can something of C beat C++ so astonishingly? WTF is the point of classes in the end if with a little more effort you can make a engine/program that runs faster? OH, MY, SOMEONE HELP! GOTO WWW.FUNCORP.CJB.NET

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
in C++ structs and classes are the exact same thing. With the only difference being that the default access-modifier of structs is public while it is private for classes.

regular class-methods are not slower to call than to call a function and pass a pointer to a struct as a parameter (as that''s how they are implemented). Actually classes might be a bit faster, because the class-pointer is passed in a register while a struct-pointer would be passed on the stack to a regular function.

virtual class-methods however are a bit slower than regular functions, because of one extra pointer-dereference. This should however be negligible unless your method is extremely small (a few instructions or so).

Share this post


Link to post
Share on other sites
Why would you program in C? Machine language is faster.

BTW, feel free to join my procedural language fan club at:

www.dinosaurs.com

alternate link at:

www.VIC20ROOLZ.com




Share this post


Link to post
Share on other sites
As classes are most often used the equivalent in C would be a structure and a series of functions that take a pointer to that structure as their first arguement. There is no performance differance between C++ and doing the same thing in C. With something like MFC versus straight Windows calls it can be slower, but that is because of all the error checking as well as checking if you used this option or that. That has nothing to do with C++ other than that it uses classes which means it only works under C++. If you wrote the equivalent in C it wouldn''t run any faster. All C++ does is provide you a formal way to do the same thing you could do in C. All it does is save you some coding and makes your programs easier to read. Chances are that how C++ does a particular OOP feature is more effecent than what you would have coded left to your own creativity.

Share this post


Link to post
Share on other sites
quote:
Original post by Sydan

Why would you program in C? Machine language is faster.



Sydan,
In response to your challenge before you deleted it, here:

VectorLerp (ClrYellow, ClrRed, 0.6, Sun.Material.Color);

So there.



Share this post


Link to post
Share on other sites
Silly me, I thought it was a serious post. I think you should skip using an assembler or compiler and just poke opcode and operands into memory then run it.

Share this post


Link to post
Share on other sites
Well, I''m using a 486/66 . . . but then again, I''m still in school; when I start my career, I''m gonna get a good computer. Then I can really get involved in real game programming. Right now, I just fiddle around here and there.



"Science is a tool. If the tool works, we use it. If it''s true, that''s great, but if it isn''t, it doesn''t matter" -- ("Desert Fox" from GameDev.net)''s physics teacher

Share this post


Link to post
Share on other sites
just a small point, lilbuddywiser, an oversight...

passing an explicit "this" pointer, ala a struct and functions, would take longer because it''s passed on the function''s stack, where as the implicit this pointer, ala a class and member functions, is passed in a register...


no biggie, just a formality.


sorry, i know you are wise, i just thought it''d be funny to catch one of the big guys

-succinct

Share this post


Link to post
Share on other sites
SO in the end........

Theyre ususally isnt a difference in seed between struct and class unless virtual is used. And class might actually be faster in some cases.

and CobraA1 is in serious need of a comp, YOU CAN ATLEAST BUY A P 200 FOR LIKE $150 at a computer sale!

GOTO WWW.FUNCORP.CJB.NET

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!