Jump to content
  • Advertisement

Archived

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

smarson

C or C++ ??

This topic is 2747 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

What are you guys using? Personaly, I think object-oriented design is the best way to approach the widest variety of game-related problems, but I can understand how many programmers would prefer the more straight-forward procedural approach, especially when system resources are tight. I''ve seen alot of your example code in VC++, but I haven''t seen anything that couldn''t be done in straight C (maybe I''ve been looking at the wrong code).

Share this post


Link to post
Share on other sites
Advertisement
well, i use normal c in my engine to make the .dll''s for the engine components .. but usually the game is in c++ .. since its object oriented...

i also use structs .. since they can be something like classes..

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I use C. That does not mean that I hate C++. C++ is based on C, right?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Object Oriented Design != C++

Share this post


Link to post
Share on other sites
Classes are good to use. Its easy and gives a lot more reliability than normal procedural based programming. In information hiding classes are really helpful.

The program can be made good with classes and private and public variables are really helpful. struct is good but it can easily be made to point to wrong values.

For example if time shouldn''t exceed 24 and not be below 0 we can use constructors in C++ but we wil have to do a lot of error checking in c.
Overall C++ is better than C.

Regarding tight hardware - just use dos. In the world of openGL and 3dfx I don''t suppose tight hardware will exist - but if it does just use dos and break your head on doing 3d(pretty good way to learn though).






Share this post


Link to post
Share on other sites
(Object Oriented Design != C++) = TRUE

Yeah, people say that C++ is for OOD alot, but in fact, C++ was designed to be a multi-paradigm language. OOD is just one of many directions you can go with C++. The anonymous poster obviously knows a thing or two about programming to point this out.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster

Object Oriented Design != C++


Er, no one ever said it was. The statement I believe you are referring to was that "C++ is object oriented" which is true and false. It has object oriented techniques built into the language but you aren''t forced to use them.

As for which language to use, both C and C++ are used in professional games, with C++ becoming more and more popular (although I believe C is still more widely used). I personally use C++ as I believe an object oriented approach makes more sense.


- Houdini

Share this post


Link to post
Share on other sites
For example if time shouldn''t exceed 24 and not be below 0 we can use constructors in C++
-----------------------------------

Huh? I really can''t see how much a constructor can help in that type of error checking as its only called once, when the object is created. Both languages really need error checking at the point of the problem. Regardless, both languages need alot of error checking, neither needing less.

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

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

Share this post


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

For example if time shouldn't exceed 24 and not be below 0 we can use constructors in C++
-----------------------------------

Huh? I really can't see how much a constructor can help in that type of error checking as its only called once, when the object is created. Both languages really need error checking at the point of the problem. Regardless, both languages need alot of error checking, neither needing less.

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



ImmaGNUman, what he is saying is that in C++ you can put in range checking in your constructor and accessor functions. This way when you or the user changes the time the range checking is done automatically and you never have to worry about explicitly calling it.

In C you'd normally have to do range checking manually anytime you change a variable in your time structure.

Of course you could emulate what C++ does by creating a function where you pass a pointer to the structure and the new value, but that begs the question of, "Why not just use C++".


- Houdini


Edited by - Houdini on January 15, 2001 1:46:23 PM

Share this post


Link to post
Share on other sites
Oh man, why do we always have to ask this question??

Personally, I mix C and C++... I make extensive use of classes in almost all my programs, but that's just about all the C++ I use... all the code for the functions are pure C

For instance, I almost NEVER use cin and cout and fstream and iostream and << and >> and the other C++ stuff... instead, I use the *printf and *scanf and for file i/o, I use C's fopen(), fread() and all that....

Also, I find myself using less and less of struct's ...

So to sum up... C++ classes give my programs a frame work, a skeleton, if you will.... all the meat of the program, meaning the code in the functions, is pure ANSI C.

my $.02 * 10

Edited by - somecodeguy on January 15, 2001 3:37:59 PM

Share this post


Link to post
Share on other sites

This topic is 2747 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.

Guest
This topic is now closed to further replies.

  • 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!