Advertisement

Ahh C or C++

Started by October 09, 2002 11:53 PM
24 comments, last by ThomasSauder 22 years, 1 month ago
Objective-C 0wnz j00!

(yeah, I''m a lama )
You guys probably scared the poor chap away.

If you can only learn from one of your books, then read the one that teaches C++ because that is more useful. You will learn alot of C at the same time anyway.

Meanwhile, you will probably find it beneficial to actually go through the book on C AND the book on C++. Don''t skip something because you are impatient to build the next killer RPG. Even those of us who know the languages fairly well are still working on checkers and pong. I took C in college, and have read at least 3 books on C and C++ since then. It doesn''t take that long to do. Also, you don''t have to know EVERYTHING about the language before you can use it. Just be sure to keep your books around so you can refer to them when you encounter something you don''t understand or you need to look up how to do something.
Advertisement
quote:
struct A { ... };struct A myvar;  

you can write this in C++:
struct A { ... };A myvar;  



one keyword, two syllables... ''typedef''
quote: Original post by Jiia
I never mentioned trying to "write C-compatible code". I mearly said that it would not be much more difficult than learning standard C structures. As in it''s okay to use classes up to the point of using member functions, until you feel comfortable enough to use the advanced features of them. Perhaps you just misunderstood.


If you didn''t talk of writing C code then yes, I probably misunderstood your intentions. But in that case... what on earth are you trying to say?

quote:
Perhaps you are of a more intellegent nature, but I had trouble grasping all of the features of classes right away. Maybe I''m the only one. Or maybe you''re too far into your greatness to remember.


You''re ready to use them, I didn''t say that you''d magically understand it all. Learning takes time and you never finish.

quote:
I consider myself to be a lazy C++ programmer. So the change is suited to lazy programmers. Where did I say that everyone that uses it is lazy? Where did I change my mind?


I might be wrong but you just first seemed to state that C++ was for lazy programmers and then in the next post you said you were a lazy C++ programmer, but anyway, you said it here:

quote:
Learning the basics of C++ IS learning C. I mean come on, all that is left are a few typdefs and other added keywords. C++ basics are just suited for the lazier programmer.


quote:
Ah, yet a true lazy programmer knows that commenting your code excessively prevents the need to scurry through it later to figure out what something does.
(snip)
Not commenting is either genious or inexperienced.


You can see another thread on the forum on commenting, it''s a holy war, we will not agree.

quote:
Eh? My post was to help someone learn something new, not master the language.


I''d presume you needed more than to learn something new to be able to sensibly work with a graphics API and do games, I could, of course, be mistaken. Not trying to diss your experience or anything, pardon me if it seemed that way.

Yours truly,
Henrik Stuart
--I am not a church numeral, I'm a free variable!
Anyway, my OPINION is to start with the basics of C++. Try to hold out on advanced topics with classes or templates until you have the rest tight under your belt. Learning C will be easy once you've mastered this much. In fact, all you'll really need to do is hold back on some of the features you've learned, use different standard libraries, and a few extra keywords. This, in my OPINION, is just as easy as learning straight C, except you've started C++.

[edited by - Jiia on October 11, 2002 6:14:28 PM]
This is why people think that C++ is a hard to learn language, and C is the good old language that should never be touched again.

quote: Original post by Jiia
Anyway, my OPINION is to start with the basics of C++. Try to hold out on advanced topics with classes or templates until you have the rest tight under your belt.


#include <iostream>
using namespace std;

int main()
{
cout << "hello world" << endl;
return 0;
}

The problem is, basics of C++ are classes. If you are about to learn C++, and you never know what classes are, what operator overloading is, congratulations, you just reach the advanced level of C++ without basics. cout is a class, << operator is overloaded. What you are studying in "basics" of C++ are indeed advanced topics. That's why some people just "don't get it."
If you are refering that the basics of C++ are if/else, for(;, do while, switch, writing functions...etc...etc...well, those are basics of C. Basic of C++ is classes. Advanced C++ is operator overloading, polymorphism, RTTI, template, etc..etc..etc. Do you want to tell people who don't know how to write variables and functions (yet) to write/use a class?


ThomasSauder, I used to be in your place, encouraged to learn C++ and ignoring C completely, thinking that those two languages are completely different. Thinking that learning C++ will also make you understand C. Too bad I was wrong. But no, I don't suggest you to learn C entirely. Grab the basics, how to write main function, if/else, for(;, do while, functions, structs, variables, typedefs, switch, etc..etc..etc...Then go learn C++ classes (which is the basic of C++). Is that gonna put you in a disadvantaging situation? No. Is that gonna teach you how to write procedural language which is not better than OOP? Yes, but read couple of first chapters in your books. WinMain() is a global function, WndProc() is a global function, those are the application of procedural language. When do the authors touch C++ classes? When he thinks that he needs data encapsulation and the benefits of OOP to simplify programming tasks due to larger projects, and to make better programs/games; unless you are using MFC, but most game programming books will cover Win32 API (which is C) instead of MFC. That's the idea.


quote: Original post by muer
Again, C and C++ require two different mind-sets and while their fundamental basics do not differ they are very different in how you apply them for actual programming. Mixing them is bad code style and should be avoided where possible


I somewhat disagree with it. If you are using Win32 API, you'd better not to say that. Most game programming books out there mix them pretty well, is it bad? Well, I don't know if people who make Doom3, EE, have bad programming style?

My compiler generates one error message: "does not compile."

[edited by - nicho_tedja on October 12, 2002 12:30:32 PM]
My compiler generates one error message: "does not compile."

This topic is closed to new replies.

Advertisement