As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
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.
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).
I found Thinking in C++ very good when I was going from C to C++.
Link broken - can now be found here
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/).
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.
Accelerated C++ is good too.
This very recent SO question asked by an inexperienced C programmer nevertheless has answers that are also relevant to experienced C programmers.
If you're already a good C programmer, you can probably jump right into the bible, Stroustrup's The C++ Programming Language.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I have been coding in java most of the time, and I also studied C and C++ at University. But I have never written a large C++ code from zero made of many files, as I have done in java with a file for each class.
I'd like to know some book or reference with exercises and examples made of many files and classes en C++, so I can face big C++ projects in the future.
Sorry if you feel this question is eternally repeated.
Large-Scale C++ Software Design, by John Lakos.
Frankly, it doesn't matter much which language you're using in the end. Good software design is good software design. I don't think you'll ever learn it from a single book - and most books that talk about that kind of thing are referring to designing large frameworks which I doubt you're doing.
Identify sub-components/functionalitities in your requirements that you can form into separate libaries (static or dynamic, read up on the difference). If you compartmentalize these components into libraries that can act independently of each other then you'll have loose coupling between libraries - and assuming you've correctly identified your sub-components, they should have high-cohesion (everything in a library is closely related).
Try and keep dependencies out of your header files whenever possible regardless of where you're coding - you should read up (even on google) about separating declaration from definition). There's a number of design patterns for this purpose (including PIMPL which I seem to be mentioning alot today).
Read the design patterns book by the Gang-of-Four, and do the above, and you'll be off to a good start. Also, assuming you're decent with C++, Effective C++ by Scott Meyers will talk about some of these topics in very helpful manners.
Good design is a key on large projects and it is doesn't matter which language do you use if you follow the OO concept.
But for some best practices in c++ you could read this book:
http://www.gotw.ca/publications/c++cs.htm
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I teach C and C++ and I was just wondering if there are good overview of the C++0x features.
I am going to read the standard, but that will take time and I'm definitely going to make it for this semester (next year hopefully). For this semester I just want to make one extra lecture about C++0x (and maybe make sure that none of the taught features are deprecated/changed in C++0x).
The best two I know of are the Wikipedia page and Stroustrup's FAQ.
I really wouldn't recommend reading the standard until you know what you're looking for. Besides being significantly larger than the C++03 standard, the organization and clarity has gotten somewhat worse in parts.
If you're only going to do one lecture on "advanced C++", you might focus on C++0x features which were adopted from other common sources, such as boost::smart_ptr and std::tr1::unordered_map. Such things are ahead of the curve on adoption.
Herb Sutter has written many articles on the changes which you might find useful.
Wikipedia has a long overview. I would hightlight rvalue references and lambdas.
There is a lot of overviews C++0x in a network. I can recommended to read a wiki page, and C++0x FAQ
I've been reading this Code Project overview:
Explicating the new C++ standard (C++0x), and its implementation in VC10
The C++ Annotations have everything available in gcc 4.4. This is a (free) book rather an overview.
Scott Meyers has a 3-day course titled "An Overview of the New C++ (C++0x)", and perhaps more interestingly, a ~335 page, $30 PDF with all the course notes (if you can't spare the time or money for the course).
I know the time & cost of the course might be prohibitive, but the PDF might be an option.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Does anyone know any site or book that presents problems like python challenge, but for C++?
When I think python challenge, I do not mean only a set of problems to be solved with C++ (for that I could probably use the same problems of python challenge), but rather problems that will probably be best solved using C++ STL, special features of the language, etc.
For example, there is one python challenge that is specifically designed to teach you how to use pickle, a serializing library for python.
Until now, I only know programming contests problems, but they could also be solved with C, java or other languages.
You might like to have a look at Herb Sutter's Guru of the Week series of articles.
Google Code Jam problems frequently have analyses with snippets of C++ code, probably because C++ is by far the most popular language used for solving code-jam problems. The latter also allows you to see many C++ constructs cleverly employed, as code-jam allows you to download the solutions by all the competitors. As most code is C++, you'll get to learn a lot of nice C++ tricks for efficient code.
There are many tasks on Rosetta Code that are not implemented in C++ as yet. Try your hand at those, especially if you can use advanced features (templates, external libraries, etc.) to produce a particularly nice solution. Remember that there is no fundamental reason why any of those tasks should be beyond the C++ language, and there's usually several other implementations in other languages to show you other ways to attempt the task, which can help a lot.
You're going to have a difficult time finding that because C++ provides less for you than almost any other language available. If C++ provides it, it's probably provided by Python or Java or C or any other programming language.
Why not try using some C++ concepts such as the STL to solve Project Euler problems?
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am looking for quick reference guide(s) for both OO and C++. I have a few technical interviews coming up and I just want a quick reference that gives the basic overview of the fundamentals. (Nothing too in depth, as I've learned it all once before)
Have a look at this C++ tutorial online.
There is also Bruce Eckel's Thinking In C++ freely available book.
C++ FAQ Lite is searchable and Herb Sutter's Guru Of The Week series feature many tricky puzzles.
Steve Yegge at google has a couple of excellent summaries of interview questions here and here.
Here's a site that's dedicated to Object Oriented Programming in C++. It provides quick coverage of the basic concepts.
For pure OO info, you might want to review the basic terminology (not C++ related) on Wikipedia's Object-oriented design page.
Stroustrup's FAQ is a good jumping off point to refresh some things. For a terminology refresher it's hard to beat the OO Wiki page.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I saw Scott Meyers' "Effective C++" third edition book having a small section on "Template Programming".
Any other book/links containing information on "effective" usage of templates ?
I like Modern C++ Design: Generic Programming and Design Patterns Applied. I found it very well written and clear. Contains a few advanced topics.
Vandevoorde / Josuttis 'C++ Templates the Complete Guide' is very accessible.
C++ Templates - The Complete Guide. Alexandrescu's Modern C++ Design is very good, but I wouldn't recommend it unless you're already familiar with templates. It's also geared more to C++ Framework creators.
I quite like C++ Template Metaprogramming by Abrahams and Gurtovoy.
Scott Meyers deals with the Standard Template Library in Effective STL. That may be relevant for you.
A rarely mentioned but solid book is C++ Common Knowledge by Stephen C. Dewhurst. "Among the first users of C++ at Bell Labs", Dewhurst gives the book a somewhat deceptive title because he actually covers quite a bit of advanced material in particular in regards to templates.
Dewhurst's book is organized similarly to Meyers's with 63 "Items" that you can usefully read on their own. On templates you should look over items 45-59 (about 70 pages of reading).