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

C or C++

Started by -RaVeN- Dec 28, 2001 at 9:16 PM 23 replies 700+ views
Original Post
-RaVeN-
-RaVeN-
hey im currently learning C++. I realized that OpenGL and WinAPI are in C and im wondering if i should stop C++ and start C , cuz i want to do OpenGL later on. Also does any1 know of any opengl books that r in C++? thanks
Pactuul
Pactuul
Flame BAIT! Anybody going to bite?

Anyways, C++ fully supports C, it basically built upon that...I believe that you''ll soon see that your not hurting yourself, because while you learn C++ your learning C.

you''ll eventually see that as you start to understand more
-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
jenova
jenova
learn qbasic. lol.

j/k. on a serious note it really depends on problem you are trying to solve and the size of the project.

i would suggest you learn c before you try to tackle c++. makes sense, don''t it.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
George2
George2
If you know C++, you know C. C++ = C + Object Oriented programming.

C++ is better but strange enough Quake 2 was written in C.
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon
Rhuantavan
Rhuantavan
Before you dig into c++, it would help to know how to program in C. That''s not a requirement of course, but it might help you better understand some c++ concepts. I would recommend you to get Bruce Eckel''s Thinking in C++ book, which is also freely downloadable at http://www.bruceeckel.com/.

Just my 2 cents....

Damjan Mozetic
Rhuantavan Project
Damjan "Rhuantavan" Mozetic
python_regious
python_regious
Oh for the love of God, do a search. You''ll probably come up with 500 other posts like this all answered for you.
If at first you don't succeed, redefine success.
Eber Kain
Eber Kain
some coders perfer C some C++ its a personal choice. Each way has its bonuses that equil out.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
zealouselixir
zealouselixir
quote:
from George2:
C++ is better but strange enough Quake 2 was written in C.



Not strange at all. Carmack has been coding in straight C since DOOM. Undeniably, if you use C++, you should use the features it offers, such as polymorphism, inheritance, etc. I believe that you can write a game without these features (actually, I know that, because 1000s of them have been), and have it be faster than its OOP equivalent. C++ has its pitfalls when not used by someone well-versed in its anomalies.

quote:
from Jenova:
i would suggest you learn c before you try to tackle c++. makes sense, don''t it.


No, actually it doesn''t. C is a subset of C++ for the most part, and C++, being OOP, allows for more organized, powerful programs. The only thing specific to C that one should learn is the stdio library, if only to see why streams came about.

Anyway, I''m not trying to incite rage against anyone, just stating my opinion. Take it or leave it, but don''t hate me for it.

Later,
ZE.
[twitter]warrenm[/twitter]
Martee
Martee
quote:
Original post by Anonymous Poster
C is a procedural language, C++ is build on classes, inheritance and polymorphism.

I have to disagree a bit here. Although C++ provides facilities for object-oriented programming (e.g. classes, inheritance, and polymorphism), it also provides facilities for generic, modular, and procedural programming. So I don''t think it''s quite fair to say that the language is built on the concepts of OOP, when it actually provides much more.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
23yrold3yrold
23yrold3yrold
quote:
Before you dig into c++, it would help to know how to program in C.
Does anyone else disagree with this? I know some people say this but then you have to flush crap like malloc() and char-strings out of your system. I can''t count how many times I see a post (not here) where some C hobbyist is moving to C++ and is mixing up the functionality; deleting things they''ve malloc()ed, or trying to int* ptr = malloc(new int); or other pure stupidity.

It''s totally a matter of personal preference; no one is better than the other. But I strongly prefer C++. And it''s not that hard; it''s the first language I ever learned and I think I''m pretty good at it.

Chris Barry
Jesus saves ... the rest of you take 2d4 fire damage.
Null and Void
Null and Void
quote:
Original post by 23yrold3yrold
I know some people say this but then you have to flush crap like malloc() and char-strings out of your system. I can''t count how many times I see a post (not here) where some C hobbyist is moving to C++ and is mixing up the functionality; deleting things they''ve malloc()ed, or trying to int* ptr = malloc(new int); or other pure stupidity.

How often do you notice a C programmer moving to C++ who doesn''t do those things? Wait, you don''t notice all of them, do you ?

This is kind of like that study where they wanted to prove having two Y chromosomes made you violent, so then went to prisons and testing the convicts'' DNA. They found that lots of convicts had two Y chromosomes, so they concluded that two Y chromosomes make you violent. However, they never tested the general population. Later, when someone did test a group of non-convicts, they found lots of normal and healthy people had two Y chromosomes as well.

[Resist Windows XP''s Invasive Production Activation Technology!]
23yrold3yrold
23yrold3yrold
quote:
How often do you notice a C programmer moving to C++ who doesn''t do those things? Wait, you don''t notice all of them, do you?
But thinking malloc() and delete (or new and free()) mix isn''t entirely illogical though; since C++ is C with more stuff you''d think the two would get along happily. It''s still extra knowledge you need to unlearn.

I''m just saying that knowing C isn''t necessary to learn C++. And I''ve actually seen it make it more difficult, so I''ll recommend against it. You want to learn C++; learn C++. All IMHO of course.

Chris Barry
Jesus saves ... the rest of you take 2d4 fire damage.
bit64
bit64
C++ is a superset of C. They are not different languages.
Please don't confuse the original poster or yourselves anymore than need be.

C++ is a superset of C that enables the programmer to design applications with an Object Oriented paradigm. However, it does not force this on the programmer, it is smiply there as an option.

"(maybe im not completely right, but im sure that there is no word like "class" in the code, all you see is "struct", wich is C)"

Structs are not C specific. In C++ a struct is a class, the only differing attribute being that its members are public by default, whereas a class's memebers are private.




Edited by - bit64 on December 29, 2001 8:37:21 PM

Edited by - bit64 on December 29, 2001 8:38:12 PM
Don't be afraid to be yourself. Nobody else ever will be.
Null and Void
Null and Void
quote:
Original post by 23yrold3yrold
I''m just saying that knowing C isn''t necessary to learn C++. And I''ve actually seen it make it more difficult, so I''ll recommend against it. You want to learn C++; learn C++. All IMHO of course.

Of course. Personally, I''m on the side of the minority that thinks that you should learn C before C++. I accept that I probably only think that because that''s what I did, and I don''t seem to have any problems doing OOP in C++ .

[Resist Windows XP''s Invasive Production Activation Technology!]
hemihua
hemihua
Personally, I would go with C for game programming. I have programmed in both, and never really liked C++, as C has a closer feel to assembly language, or a more direct correspondence to what is actually going on when it is compiled. Also, every time you call a function in C++, it has an overhead of 1 extra parameter passed on the stack than C. Really it is personal preference, I can''t stand having the unnecessary addons of C++ because it hurts speed, others don''t give a shit.
23yrold3yrold
23yrold3yrold
quote:
Really it is personal preference, I can''t stand having the unnecessary addons of C++ because it hurts speed.
Now THAT''s flamebait Both languages produce fast code when you know what your doing. The speed difference is negligible, if it exists at all. True, some parts of C++ are a touch slower, but no one''s making you use them. And if you really want to be anal, use asm() :p

Chris Barry
Jesus saves ... the rest of you take 2d4 fire damage.
BaShildy
BaShildy
Both languages have their uses, unlike some of the people on this board who think now that c++ exists there is no reason to go back to the wicked ways of c. If your going to start out with c++ please spend a lot of time with pointers. They are very important, and most people don''t understand them completely. Just because C++ lets you dance around them at times does not mean you don''t need to avoid learning them. I would recommend you learn C first just so you can get comfortable with its basic concepts. Then you can move onto c++ and learn good oop practices.

When you get comfortable with C/C++ and what other languages you learn, you can then pick what language is best for the job. There is no perfect language, so the more languages you learn the better programmer you''ll be.



Code comment of the week:
bool hack = false; // DO NOT CHANGE THIS EVER
Kevin "BaShildy" KingGame Programmer: DigiPenwww.mpogd.com
Eber Kain
Eber Kain
Mabey it will come clear if someone talks about C#

In the beginning there was C
Then there was C++ - C with OOP
Now there is C# OOP only
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.

Topic Locked

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

Sign in to reply to this topic.