Best way to learn c++?

Caporegime
Joined
12 Mar 2004
Posts
29,962
Location
England
Well since I have finished my sql programming course early at school I have 6 weeks of I.T. lessons with no work to do in, so I thought I should teach myself c++ in the lessons instead. I have been learning it so far using the tutorials on www.cprogramming.com , what is generally regarded as the number 1 book for learning c++?

And what is the difference between C, C#, c++ etc?

When it comes to learning graphics programming, which would you reccomend learning directx or opengl? Most games that I've seen seem to use directx?
 
Basically C is a non object orientated imperative language. C++ and C# are object orientated.

Now C/C++ you need to manage memory by your self (allocate/free it etc..) Where as C# is managed so it takes that work off the programmer. Both have their disadvantages and advantages.

I don't really think there is a number one book for learning C++ (Like K&R was for C). I used Deitel and Deitel C++ How to program. Which seems pretty dam good and has a load of examples/exercises to work through (Its a little on the expensive side though). Though I did have experience from C/Java before.

If your going to code for the windows platform I would go with directx. Most modern games use it these days however I found it to be harder than opengl to do basic stuff with and the api names were less than intuitive. Saying that there is a massive amount of tutorials out there for opengl (Nehe for instance).
 
I think the best way to learn each respective language is to make something with it, and leaf through a reference manual whenever you're stuck.
 
I learnt the bit of C#I know by using the NeHe tutorial and OpenGL. Tough going at first but progress is made easier by having something pretty good to show for your efforts.

I didn't find C# to be much like C or C++, probably more like Java, but then maybe that's just me. To learn C++ I'd first learn C for a while, then learn about Object-Oriented stuff and why things are done that way, before embarking on C++.

The 21 day/hour books are a mixed bunch. I found the XML one fairly decent, but the ASP one worse than anything I'd ever come across. They tend to make rapid progress whilst not filling in the detail so you never get a real understanding of what's happening. And not understanding something at the start only leads to problems later on. Again, just my opinion.

If you want quick and quite impressive results I'd go for C#. If you want a tough challenge, albeit one that's going to deliver a whole lot more speed to your graphics, go for C/C++ .

Jim
 
matja said:
I think the best way to learn each respective language is to make something with it, and leaf through a reference manual whenever you're stuck.

/Agreed

Thats how I tought my self C++, think of something simple to start of with and slowy progress from there, the key thing is make sure you finish the program off and do not byte (hehe) more that you can chew.

As Chaos says gamedev.net is the best place to start. Wish I had access to it when I started with C++.

The book I found invaluble is C/C++ Programmer's Bible you look on any online book store you should be able to get it for around five quid now.

As you get deeper into C/C++ get your self a reference on data structures. As once you have mastered these you can pretty much do anything.

A must read for any programmer is Code Complete, but this is more a do and don'ts in programming than an how to program book.

Anyhow

Good luck matey :P
 
Now I'm unsure of wether to learn C# or C++ lol. Later this year we are doing a java course, do you think I should start learning java earlier instead?
 
I guess you're really going to be developing coding (and possibly OO) skills, and any of those languages will do that. Once you've got the theory down learning the basics of each language will be relatively straightforward. A matter of syntax, available libraries, and (largely in the case of C++ which I found difficult) some memory management.

I think if you're getting on well with C++ then continue with that. Learning Java or C# would, IMHO, be an equally good move as both are widely used, are very versatile, and (in the case of Java) as you're going to be doing it anyway it's going to be effort well spent.

Jim
 
You know on second thoughts I will stick with c++ for now. I tried eclipse and netbeans and god they try to make it complicated, creating classes etc, settings up directories, tons of errors. With bloodshed dev c++ it just lets me start coding straight away. I think I'll let my teacher sort out all that stuff. :p
 
Netbeans can be a pig to set up but once you get that out of the way it is a very good IDE.

C# and Java are almost identical in their structure and syntax, so it is a very small step to go from one to the other. C# is my prefered language and while it does run on a virtual machine, like Java, I believe it has very limited support on non-Windows Operating System. [Java on the otherhand works on most major platforms].

The big difference between C# and C++ is indeed memory management. You have to be incredibly aware of what you are doing in C++ as a wrong pointer could really wreck your day! While I don't actually know any C++ myself [never found the need for it] in your position I think I would go for C# or Java first. I think it more important you get your head around Object-Oriented programming and how it all works without the added worry of memory management, then go on to use C++ with that knowledge.

Whatever you choose in the end, all programming languages will have similarities and once you understand various data structures and how they interact, moving to a new language should be easy, as all you need to learn is the different syntax. As a case in point, I have recently started teaching myself PHP. The book I am working from goes into detail about various things such as arrays and variables etc. I can happily skip past all this since I know it from previous languages. The only thing I have had to learn is the syntax [which isn't entirely unfamiliar].
 
SiriusB said:
Netbeans can be a pig to set up but once you get that out of the way it is a very good IDE.

C# and Java are almost identical in their structure and syntax, so it is a very small step to go from one to the other. C# is my prefered language and while it does run on a virtual machine, like Java, I believe it has very limited support on non-Windows Operating System. [Java on the otherhand works on most major platforms].

The big difference between C# and C++ is indeed memory management. You have to be incredibly aware of what you are doing in C++ as a wrong pointer could really wreck your day! While I don't actually know any C++ myself [never found the need for it] in your position I think I would go for C# or Java first. I think it more important you get your head around Object-Oriented programming and how it all works without the added worry of memory management, then go on to use C++ with that knowledge.

Whatever you choose in the end, all programming languages will have similarities and once you understand various data structures and how they interact, moving to a new language should be easy, as all you need to learn is the different syntax. As a case in point, I have recently started teaching myself PHP. The book I am working from goes into detail about various things such as arrays and variables etc. I can happily skip past all this since I know it from previous languages. The only thing I have had to learn is the syntax [which isn't entirely unfamiliar].

You do have a point but in my experience, I have found that learning about memory management earlier on help me a great deal when learning about OO, sure it’s a pain in the arse but learning about how pointers work, how all allocate and de-allocate memory helped when learning about the different design patterns etc in OO.

I remember doing OO during my masters where we were given a assignment to design an app and code it in C++, those who just learned java / etc during there BSc course (staffs uni I find is really bad for this) did not have a clue about how to go about it.

Learn C++ first mate it appears you are getting on well with it anyhow, learn about data structures and memory management, you will find such things as java etc much easier to grasp later on if you wish to go down that rought. It will also help when you want to do some graphics programming as well.
 
Back
Top Bottom