How should a C programmer learn C++?

Quora Feeds

Active Member
Robert Love

I am a long-time C programmer who learned C++ later in his career. It isn't hard. I suggest a two-pronged strategy: Practice and study.

Practice, the most important part of learning any programming language, is easy in this case. You already know C, so start doing what you'd do in C, but in C++. Take an existing (small) program you've written and convert it to use classes. Or convert a library you've written into a parameterized version using templates. That is, take an existing work of yours, pick a feature of C++, and mash the two together. You don't need a book to do this. Let the compiler and example source you find on the web guide you.

Then, for your next project, code in C++ instead of C. Do this gradually; you don't need to write idiomatic C++ on day one. Move slowly, using what little C++ you know. If you are just writing C++-correct C at first, that's fine. Next add classes. Let the C++ compiler and your existing code base pull you deeper and deeper into C++.

Next, if you are afforded the opportunity to work with a team or on an existing C++ project, you'll be able to dive head-first and start making meaningful contributions in C++. You'll continue to learn more as you read and write more C++. This was my case and in fact I never read a full C++ book. But if you don't have a team or existing project to support you, you will want a book to help you learn the details and more complex topics that you won't master from working on your own. Since you already know C, I recommend Accelerated C++: Practical Programming by Example. It moves quickly, teaching you everything you need, but without fluff. It assumes you know how to program already—just not in C++—thus it is a perfect fit.

Regardless of whether you move on to self-study, you must read Meyers' Effective C++. It is an excellent book on C++ best practices.

(By the by, 90% of the value of C++ is captured by learning classes and the better-C-than-C features of C++. Unless an existing code base demands it, you can at first ignore exceptions, RTTI, anything but the simplest uses of templates, operator overloading, streams, even the STL. This is why I believe it is easy to learn C++ as a C programmer: The parts you ought to care about are easily learned and applied incrementally.)

See Questions On Quora

Continue reading...
 
Similar threads

Similar threads

Top