70

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.

Edit: The link in the top voted answer seems to be broken right now but the file appears to exist in multiple places - e.g. here.

Mick
  • 8,284
  • 22
  • 81
  • 173
  • Here's an online class just on this: https://learninglineapp.com/courses/36/develop-cplusplus-applications – Michael Kennedy Apr 05 '13 at 18:39
  • 2
    There'ss a Coursera class 'C++ for C programmers'. You can look at the videos in preview lectures. https://www.coursera.org/course/cplusplus4c – Nikhil Mar 31 '14 at 21:29
  • For newbees who are looking for C++ Tutorial, try this one - https://www.tutorialkart.com/cpp/ – arjun May 26 '20 at 14:19

7 Answers7

38

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).

Mick
  • 8,284
  • 22
  • 81
  • 173
Donut
  • 110,061
  • 20
  • 134
  • 146
  • 2
    A Perfect answer in one minute flat... I love stackoverflow.com! – Mick Sep 14 '09 at 13:57
  • 7
    After having read about a third of it, I can report that the tutorial is superbly written. – Mick Sep 14 '09 at 14:19
  • 7
    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 Sep 15 '09 at 09:37
  • 8
    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 Sep 15 '09 at 09:42
  • 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 Sep 15 '09 at 10:15
  • 5
    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 Sep 15 '09 at 10:19
  • Not quite - I do absolutely need to use *some* genuine C++ functionality, but exactly which, and why, would take too long to explain. – Mick Sep 15 '09 at 10:23
  • 1
    @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 Sep 15 '09 at 12:42
  • 5
    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. – Johan Kotlinski Oct 31 '10 at 11:52
  • 3
    According to the reviews on Amazon, the recommended book is useless for this task (probably for any task). – JonnyJD Jan 15 '14 at 13:16
  • 1
    For the record my original "superbly written" comment was in reference to the link, not the book (I never looked at the book). – Mick Jun 29 '17 at 11:06
  • 1
    the link to the tutorial is broken :/ – DarkCygnus Aug 01 '18 at 16:40
  • the link is broken,please can you send any current active link? – mayank raj Apr 17 '20 at 13:32
14

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

Link broken - can now be found here

Steve Fallows
  • 6,274
  • 5
  • 47
  • 67
6

I'd like to suggest the New C++ Super-FAQ created by Bjarne Stroustrup, Herb Sutter, Andrei Alexandrescu, Pearson / Addison-Wesley Publishers and Marshall Cline (http://www.parashift.com/c++-faq/).

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
5

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
  • 219,715
  • 46
  • 258
  • 445
3

Accelerated C++ is good too.

StackedCrooked
  • 34,653
  • 44
  • 154
  • 278
  • 4
    A very bad book for C programmer! teaches you what variables are etc. a waste of time. – 0xFF Apr 05 '12 at 21:29
2

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

Community
  • 1
  • 1
Ash
  • 60,973
  • 31
  • 151
  • 169
2

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

me22
  • 651
  • 3
  • 8