tags:

views:

485

answers:

7

I have been programming exclusively in C for 25 years but have never used C++. I now need to learn the basics of C++ programming. Can anyone recommend an online tutorial (or failing that a book) that would be most suitable for me. Thanks.

Edit: I actually needed the C++ purely for the purposes of adding a couple of dirty hacks to a huge and old C program. Converting the entire program in to properly written OO code is entirely economically unfeasible. Some people have criticized the suggested solutions based on the fact that they will lead me down the path of becoming a "C programmer who knows some C++ without getting in to the proper spirit of C++" - but actually that fits my requirements perfectly.

+4  A: 

This might be of some use: C++ tutorial for C users.

If you're looking for a book, check out "C++ for C Programmers" by Ira Pohl (Amazon).

Donut
A Perfect answer in one minute flat... I love stackoverflow.com!
Mick
After having read about a third of it, I can report that the tutorial is superbly written.
Mick
Well done, the perfect way to create yet another programmer treating C++ as a better C. That is **not** the way to go if you want to retain your sanity. Treat C++ as a separate language to be learned on its own, not just as "a few extras on top of my C"
jalf
Hey, it gets better. It doesn't even use C++ strings. It is written by someone who doesn't know iostreams either (he manually calls .close() which isn't necessary), he doesn't know about (or understand) initializer lists. Please, do yourself a favor and *learn C++*. This tutorial won't do that for you. It will teach you a few bits and pieces of the syntax of C++, but not all of it, and most definitely not how it should be used.
jalf
Actually for my purposes its just fine. The program is *way* to big to properly re-write anyway. I just needed to convert it to C++ for some rather technical reasons and I wont be using much C++ functionality ever on this project.
Mick
You're not converting it to C++ though. If you simply want to make a C program compile under a C++ compiler, you basically just have to insert a few explicit casts here and there and you're done. You don't even need this tutorial for that. Just try to compile it, see where it complains. But this tutorial only teaches you how to write needlessly error-prone and hard-to-maintain code, and pretends that this is C++.
jalf
Not quite - I do absolutely need to use *some* genuine C++ functionality, but exactly which, and why, would take too long to explain.
Mick
@Mick: You do absolutely need to learn C++ in order to write C++ programs that contain even only _some_ genuine C++ functionality, but exactly why you need that would tale too long to explain. There are, however, a few very good books recommended and the C++ FAQ. Any of these will explain this in detail. (And any of them by itself would do better than ten online tutorials creating yet another "C with classes and some randomly sprinkled C++" programmer).
sbi
The online tutorial is really poor. Mentioning exceptions in passing as "one more control structure" = complete fail... It's better to just stick to C than starting to program in C++ without really understanding it.
kotlinski
+2  A: 

This very recent SO question asked by an inexperienced C programmer nevertheless has answers that are also relevant to experienced C programmers.

Ash
+4  A: 

I found Thinking in C++ very good when I was going from C to C++.

Steve Fallows
+4  A: 

Accelerated C++ is good too.

StackedCrooked
+5  A: 

Dont' forget to read FAQ.

adatapost
+2  A: 

If you can get hold of a 2nd edition of Scott Meyer's "Effective C++", that should help, as it was written for former C developers. It lists 50 rules that you should follow which are easily to remember, thoroughly explained, and fun to read. (Scott's goal was to write the "best 2nd C++ book" one should read an I think he succeeded in that.)

The 3rd edition of the book was completely overhauled and targets developers coming from C#, Java etc. more than earlier editions. It might be good read nevertheless.

sbi
+1  A: 

If you're already a good C programmer, you can probably jump right into the bible, Stroustrup's The C++ Programming Language.

me22