Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was asked the following question at a recent job interview:
What do you think is the main theme / single word that sums up the Effective C++ series from Scott Meyers?
What would be your answer to this question?
In one word it's Advice
My answer would be "I'm not sure, I learned C++ without reading that book."
The two older editions gathered advice especially helpful for people switching from C to C++. Using new/delete instead of malloc()/free() and OOP was all new back in 1991.
The 3rd edition is more targeting people switching from other languages (Java, C# etc.) to C++. It comes with advice on patterns, templates, exception safety, a much richer standard library, and many other topics people didn't think about in 1991.
Basically, Scott Meyers' goal has always been to write "the best second C++ book to buy" - not something to teach you the language, but to become a real professional. He wanted to list the "50 most important pieces of advice for practicing C++".
Oh, and something we shouldn't forget: He wanted it (and succeeded in doing so) to be a technical book that's fun to read.
Although a very strange question to ask in an interview (considering your candidate might not have read such an excellent book), I would say the main theme of Effective C++ is to take the path of a semi-expert C++ programmer and adjust his/her way of thinking (especially towards the internals of C++) on the path of becoming an expert.
One thing I learned a lot about is self checking of references (Page 71, Item 17). Better memory management. Preferring new/delete vs malloc and free (which is obvious but his reasonining was very well stated). Another good one was Item 29 on page 123, avoid returning "handles" to internal data.
It is not a simple read, and it is definitely not a beginner's book. It's the next leap for a C++ programmer looking to become a better C++ programmer.
It was a very good book and although it's a little dated it is one of the best books to become a proficient C++ programmer. I still read portions of it to this day, and I'm definitely NOT a C++ expert; it's a hobby.
To impress the person interviewing you mention that although you liked Effective C++ that the interviewer should take a gander at More Effective C++. Explain some of the pros to this book as well and ask he/she if they too have read it considering they've read Effective C++. That should stump the chump :).
That C++ is an insanely complex language with lots of tricks, tips, idioms and odd constructions that you have to know by heart rather than being enforced by good language design?
Probably not going to get you the job at anywhere except MSFT though !
Don't
{blah body too short blah}
C++ gives you enough rope to hang yourself with. However, you can write solid code using it, if you follow these guidelines.
Guidelines to write better C++.
Main (plagiarized) theme: "With great power comes great responsibility"
How to write effective C++?
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm a Perl5 programmer for 7 years and I'm trying to learn C++ now.
Some of the C++ syntax is hard for me to understand and to think in C++ way.
For example:
In Perl, you can mix the data in the arrays
#array = (1,"string",5.355);
You can assign any value to a scalar variable:
$var = 1;
$var = "string";
$var = \$reference_to_scalar;
There are many examples.
A friend of mine recommend me the book "Thinking of C++" by Bruce Eckel, but I haven't any C background and it's hard for me to understand some things.
So my question is - could you recommend me a book for this situation. I don't want to learn C. I understand OOP (I'm getting more familiar with C++ oop aswell), I understand the point of the pointers (and some arithmetic) and references (widely used in Perl).
I don't need manuals for dummies (what is int, bool, double, if, while), I just need a direction how to learn C++ from the perspective of a Perl programmer, because I'm sure that there are many like me.
Thank you in advance.
EDIT: Thank you for all the recommended books and the answers, I will try with "Accelerated C++". I will start from the beginning and try to change my mindflow to C++. I have added the "beginner" tag.
"C++ For Perl Programmers" is a pretty specific request. Given that Perl abstracts away more of the machine than C++ does, I think that a good way to start would be to forget what you know about Perl and get a regular C++ book.
For example, it seems reasonable to you that you should be allowed to have multiple data types in an array, because a Perl array is a higher-level construct than just a series of contiguous words in memory. If I were going to go from an array in C++ to one in Perl, I would say that a Perl array is like a C++ array that holds pointers to data instead of data (if that is even true - I am not a Perl programmer so it may not be. Maybe a Perl array is more like a linked list data structure. In any case, you get the idea.) Going backwards, IMO, is not quite the same.
As far as the book I'd recommend - there are a lot of good ones, so it depends on the style and depth you're looking for. I think Accelerated C++ is great for ramping up - its thorough and covers a lot of ground without inundating you with the tedious details.
Don't bother with learning C unless you want to know C. Programming in C++ is nothing at all like programming in C. I realize most books and teachers claim otherwise, but they're wrong. You should be looking for the exceptions, such as the previously mentioned, "Accelerated C++."
You won't find any books that will help you write code like the code you've just shown. Perl is a very weakly typed language and C++ is exactly the opposite: a strongly typed language. There are, however, ways to get kind of what you're showing in your post in various boost constructs such as variant and tuple.
I would suggest though learning C++ as a totally independent language before stepping into that kind of thing. Don't learn C++ as a Perl Programmer, learn it as a complete newb. You may be bored with the first few chapters but in the end you'll have a better grasp of the style and powers unique to C++ vs. those unique to Perl. I haven't seen any "Xlanguage for Ylanguage" book that will get you there.
I've gone through the opposite process. One of the first things I learned was that while you can write Perl code that looks like C or C++, you shouldn't. The same goes for you. You can probably find a way to write Perl-ish C++ code, but don't bother. The languages are too different. You need to learn how to write C++ code as a C++ programmer. Several goods books have already been suggested. I think you should augment that by finding a mentor. You'll get immediate feedback if you're doing things the right or wrong way. You can also check out the C++ FAQ Lite, especially chapters 28 and 29 on issues for new C++ programmers.
The biggest difference is that C++ is strongly typed. Every variable has a type, and it doesn't change. Your example Perl code is technically possible in C++, but it requires an extra library that I'm not sure you're ready for yet. Instead, the C++ way is to think about a collection of mixed but related items as their own new type - a struct or class.
Another great option is to post specific C++ questions here on SO. We encourage beginner-level questions as long as they're clearly worded and show some prior effort.
I tried to learn C++ from the "Thinking in C++" book. I found it very, very hard to learn from.
A much better book for someone starting in C++ is "Accelerated C++: Practical Programming by Example" by Andrew Koenig and Barbara E. Moo
I second Thinking In C++. I read it after knowing perl, and I found it very good. The second edition doesn't assume C knowledge; here's what it says under Prerequisites in the Preface:
In the first edition of this book, I
decided to assume that someone else
had taught you C and that you have at
least a reading level of comfort with
it. My primary focus was on
simplifying what I found difficult:
the C++ language. In this edition I
have added a chapter that is a rapid
introduction to C, along with the
Thinking in C seminar-on-CD, but I am
still assuming that you already have
some kind of programming experience.
In addition, just as you learn many
new words intuitively by seeing them
in context in a novel, it’s possible
to learn a great deal about C from the
context in which it is used in the
rest of the book.
As danben said, you pretty much just need to "forget what you know about perl". It's useful to know perl just because it's another programming language (C-like, even), but it's nowhere near similar enough to just "learn the differences".
Also: Thinking In C++ is free for the electronic version.
I work with Perl exclusively for my day job and program C++ for fun on nights and weekends. They require totally different mind sets. You're better off approaching C++ as a noob programmer and learn it from 'Hello World' on up. Sure you can fast track over general concepts such data types, but still pay enough attention to know your short from your long and your reference from your pointer.
I would avoid learning C first unless you really need to know C. Character handling in C is a pain and not suited for what I suspect you want to do. The String class in C++ is your friend: learn it, live it love it!
Actually, since you already know an imperative language, learning C won't take you much time at all. The basics are all the same -- if statements, while loops, for loops etc. Even the way the namespaces are organized are similar (although the guts of course are different.) You might want to gloss over some of the pointer handling, as C++ does references a little differently, but you would not be doing yourself any harm by picking up and reading through a copy of K&R (the official C reference) at least once. (Every decent programmer should have a copy on his bookshelf as a reference, anyway.)
After that, pick up a recent edition of Stroustrup and have at it, ensuring that you work through the exercises. Some of the concepts may be a little foreign to a Perl-oriented mind, but it won't be too strange. If you encounter a particular concept you find tricky, post again on SO and there will be lots of people happy to go through it with you!
(source: wikimedia.org)
(source: att.com)
My university recommended us this book : http://www.lrde.epita.fr/~akim/ccmp/assignments.html#C_002b_002b-Primer
Anyway, Thinking in C++ is available on the web for free. You could find the link on the previous link I gave you.
Good luck :)
Here you can find a vast variety of free downloadable/online books.
The Stroustrup book is a little hard when learning the language, its better to try another book and use the Stroustrup book as a reference.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm a practicing C++ programmer (on Unix and gcc 3.x) for the past 6-7 years. I've read Scott Meyer's Effective C++, More Effective C++ and Effective STL cover-to-cover and have lived and practiced his suggestions/techniques along with Boost. I would like to move on to the more advanced aspects of C++ - something along the lines of 'Modern C++ Design' by Andrei Alexandrescu. However, before starting to read this, I am wondering if I should spend time reading Herb Sutter's Exceptional C++ books as well. How would you compare the Effective C++ series with Sutter's books?
Thanks a lot in advance for your response.
Read as much as you can - differing perspectives are always valuable.
Yes, absolutely. Herb Sutter covers a lot of very important, but generally poorly understood areas of the language and provides lots of useful guidance for writing more robust code.
While it's true that much of the material originated on the gotw site, it is expanded and better organized in the books. If you can answer all of the problems correctly then you find that you are very rarely faced with code that you don't understand why it behaves like it does. You may also find yourself heading off many potential problems that you spot in code before they become real issues.
I got a lot more out of the Exceptional C++ books than I did out of Effective C++, but this is going to be a very personal thing.
Frankly, Herb Sutter yanks a lot in the exception safety ever since the introduction of the idea in one of the journals of the pre-2000 age. The fact he used it a lot on replication and transactional systems makes sense, and unless you are a huge follower and interested in only the software of such 'safety' kind you will be bored to death. Meyers is far more practical and engaging.
Besides, if you want to move on, there are other books in the series, notably from the legends and not the writers for the sake of writing. Look up the bits from Nicolai Josuttis (C++ Templates: The Complete Guide), Aleksey Gurtovoy (C++ Template Metaprogramming) and more recently 'Daddy 2' Stepanov. In my opinion, they are more influential, knowledgable, practical and shaping than anything DDJ or exception safety induced writeups...
And of course, if you ever need to go back to basics (and there is always a reason to), one of the best possible books on the subject is by the daddy himself: The C++ Programming Language (most underestimated and skimmed over book out there).
Read The Definitive C++ Book Guide and List. "Exceptional C++" is on the list.
I like the C++ Coding Standard book because it's just that, a coding standard.
Effective C++ introduces important ideas, and was my first read too. C++ Coding Standards however is shaped like a coding standard, which any person programming should have. There are a number of other coding standards available, Sutter's one has the advantage of being concise and well explained (only 100 items very neatly classified).
I would take the time, if I were you, to read the C++ Coding Standards and the Guru of the Week entries before moving on to meta-template programming.
Meta-template programming is interesting. I loved Modern C++ Programming and its approaches. However it is less used in practice I think, strengthen the basics as much as you can, then you can always play around with 'new' ideas.
I would absolutely recommend the Exceptional C++ books if you're looking to move into more advanced C++. My sense from reading both series is that the Effective C++ books tell you how to write code that doesn't completely suck, and the Exceptional C++ books tell you how to write code that's rock-solid and bulletproof. I was less taken with Modern C++ Design; if you want to get into serious template metaprogramming it's pretty much the definitive work, but I found it a little... out there for my taste, particularly where he builds this gloriously complicated template structure that'll bring tears to your eyes with its sheer beauty, and then mentions "Oh yeah, this doesn't actually work on any compiler that's currently available".
I found both books interesting and useful. There are lot of common topics and you might already know them, but certainly it will help.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm something of a new, reluctant convert to C++ from a Pascal, Ruby, and PHP background. I haven't worked with Pascal since a few months of torture with "Delphi Turbo;" since then I've practically been eating and sleeping Ruby and PHP. I'm already well acquainted with object oriented programming and many various subjects.
My main trouble is that I already know the rudiments of C/C++ programming, less the actual experience of working with C++. I worked with C for long enough to realize that even without macros, etc, I didn't want to work with it. (Some of the disgust was from maintaining a CGI application in C, when accustomed to Pascal's automatic string management.) I know just enough C++ to be dangerous to myself and anyone else unwitting enough to use my "code."
I'd really like to work up to a good enough understanding of C++ to use libraries like Crypto++ and Boost without major problems or in-depth knowledge of the language's intricacies. I just need to figure out how to work with C++ without killing myself (either with C++, or with the long-standing dislike that I'm already battling).
What are effective resources that will teach me C++ without assuming that I must be retaught all basic programming? I'd rather not relearn concepts that I already know, unless the paradigm in C++ is significantly different. I'm also learning on my own time, so don't recommend me a book complex enough to need a guru to explain to me, please! And I have an effective budget of $0 for learning C++, so please keep suggestions to quality online resources or books common enough that I could likely find them at the library.
Read Effective C++ by Scott Meyers - it's a good guide for getting past the basics of C++ and showing how to write and use "correct" C++ code
The C++ FAQ Lite is a great resource.
I highly recommend Stroustrup: The C++ Programming Language (Third Edition). As the author of C++ he is the authority on the language, and the book is useful as a reference as much as it is for learning the language. It's common enough that most good general purpose libraries will have a copy. He goes into quite some depth on all the features of C++, including explanations of why certain design decisions were made in the language. Personally, I think this is the best book around for programmers to learn C++.
Once you have a good grip on core C++, David Abrahams and Aleksey Gurtovoy's book, C++ Template Metaprogramming, goes into further depth and provides many examples of how C++'s template system allows you to perform complex compile-time programming, a highly valuable skill these days. This one is a little less common but you can probably find it at a university library.
I can give you a couple of keywords you might want to research in more detail:
RAII (Is pretty much the technique that ensures you don't have to worry about memory leaks. Very convenient)
Generic Programming (The STL in particular. Experiment with iterators and the standard library algorithms, and see just how powerful these abstractions are. They're a key part of what I like about C++)
Functors (Perhaps too simple on their own, but the way they can be used instead of function pointers with the algorithms mentioned above is interesting)
And just get familiar with templates, and "mild" forms of template metaprogramming. (Traits classes, for example, and (partial) specializations.
And just keep an eye on the C++ questions here on SO. A lot of interesting topics are regularly brought up.
But the best advice is probably to keep it completely separate from C. Forget everything you learned about how to use C. It either doesn't apply in C++, or leads to inferior code that is harder to read and maintain.
It's an interesting language in its own right, and has a number of unique features. Leverage those, and it can actually be fun to work with C++. Treat it as an overengineered Java, PHP or C, and it'll just make you want to throw up.
You need to write code. A lot of code in C++. There is no substitute. You also need to read good code.
I agree with the suggestion for Scott Meyers' books though. Those are pretty good.
Part of your learning will be the leap from procedural programming to OO.
I would highly recommend the book "C++ Common Knowledge" by Stephen C. Dewhurst. Don't know if it's common enough to be found at the library (it's not at mine, but my library sucks for computer books that aren't 5-10 years out of date), but it does an excellent job of taking the complex aspects of C++ and making them easy to understand, without dumbing anything down for beginners. Definitely worth the investment.
To quote from the back of the book:
This book is for you if
You're no "dummy," and you need to get quickly up to speed in intermediate to advanced C++
You've had some experience in C++ programming, but reading intermediate and advanced C++ books is slow-going
You've had an introductory C++ course, but you've found that you still can't follow your colleagues when they're describing their C++ designs and code
You're an experienced C or Java programmer, but you don't yet have the experience to develop nuanced C++ code and designs
You're a C++ expert, and you're looking for an alternative to answering the same questions from your less-experienced colleagues over and over again
C++ Common Knowledge covers essential
but commonly misunderstood topics in
C++ programming and design while
filtering out needless complexity in
the discussion of each topic. What
remains is a clear distillation of the
essentials required for production C++
programming, presented in the author's
trademark incisive, engaging style.
Here is a link to a question with answers that should help you.
https://stackoverflow.com/questions/1227764/i-need-to-improve-my-c-skills-fast-is-this-realistically-possible/1227805#1227805
For effective stuff you can find online Cplusplus.com has a pretty good reference and information.
If you can find the book "C++ Common Knowledge" (Stephen Dewhurst) at the library or cheaply online, I would add that to the list posted on the StackOverflow link above as well as "The C++ Programming Language" (Stroustrup). Going through the questions under the C++ tag right here on SO should give you some good pointers and code examples to get you on your way.
Here's a list of good C++ books which teach you C++ rather than basics of programming.
Sit down and write some C++ code.
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 a Phone interview coming up next with with a company which works in financial software industry. The interview is mainly going to be in C++ and problem solving and logic. Please tell me the method of preparation for this interview. I have started skimming through Thinking in C++ and brushing up the concepts. Is there any other way I can prepare?? Please help.
Edit:
Thank you all everyone for the advice. I just want to add that I am currently fresh out of grad school and have no previous experience. So Can you suggest some type of questions that will be asked to new grads??
Make sure you know your basic data structures and algorithms. You're more likely to be asked about that stuff than something higher up the food chain. Those are usually saved for the in-person interview.
Put another way: be solid with the fundamentals and solid with your C++ syntax. Also, knowledge of common libraries like STL and Boost couldn't hurt...but be sure you know what those libraries give you! In the end phone screens are there to cull out people who can't do the basics. Prove you can and you should move on to the next step. Good luck!
Here's some links of interview questions to check out:
C++ Interview Questions # DevBistro
C++ Interview Questions # Blogspot
C++ Interview Questions # FYI Center
Steve Yegge's Five Essential Phone Screen Questions (added this in response to your edit. This isn't C++-only, but a lot of it applies to C++ and I think would be a good read in your situation).
Now, for completion's sake, some books:
Scott Meyers "Effective" series (Effective C++, More Effective C++, Effective STL)
Herb Sutter's "Exceptional" series (Exceptional C++, More Exceptional C++, Exceptional C++ Style)
The C++ Standard Library by Josuttis
C++ Primer by Lippman et al
Stroustrup's text as a reference
I have interviewed several candidates specifically focusing on their C++ knowledge, and if there was one question that worked well to put peoples' knowledge of C++ on a gradient, it was this one:
Fix this memory leak as robustly as you can:
void doSomething()
{
Foo* pFoo = new Foo();
[do some stuff]
}
+1 for putting delete pFoo at the end
+2 for putting pFoo in a std::auto_ptr
+3 for knowing what RAII is - the concept, if not the acronym
+4 for mentioning exception-safety guarantees of the auto_ptr
+5 for putting pFoo in a boost:shared_ptr
+6 for knowing when a shared_ptr might not be freed.
+7 for talking about garbage collection techniques to fix circular references
This always worked to show how long someone had been working with C++. This is one datapoint you can use to tell where you are in the scale of C++ knowledge.
Edit: I would recommend someone for hire at level 3 or above.
Try some practice problems on TopCoder.
Check out Marshall Cline's C++ FAQ. Its a good way to learn some new stuff and bone up on the things you already know in case the decide to ask you some 'knowledge' questions as opposed to 'problem solving' questions.
Grab a knowledgeable friend and have them ask you some C++ programming problems that you can solve on a whiteboard. A lot of interviews will have you solve a problem on a whiteboard, and it can be disconcerting to think on your feet and write things out in front of someone if you are not used to it.
Even if they're interviewing for a C++ position not all questions may be specific to C++. For example, I've been hit with questions related to the following all in the same set of interviews for a single C++ position:
Algorithmic complexity of well known sort and search algorithms
Multithreaded programming
Multiprocess programming
Sockets programming
Software development philosophy / approach
Software test and validation philosophy / approach
Debugging
Benchmarking
Dynamic and static analysis of code (e.g. run-time memory leak detection vs compile-time)
In my case, the phone interview was part of a screening process to determine if I could take an online C/C++ knowledge test (e.g. through BrainBench). The online test results then determined if I would be flown out for on-site interviews, which also included more "hands-on" software development tests.
YMMV. A lot depends on what you claim on your resume, as well.
Interviewers often try to help you by giving you hints so that they can see if you can arrive at the answer they're looking for. Besides gauging your knowledge, they also want to see how you think. Occassionally you might get a crummy interviewer that is neither helpful nor positive. The key is to be confident in your abilities and be truthful.
HTH and good luck!
Something which I am starting to believe is that there is sometimes a clear divide between candidates that enjoy programming as a hobby versus those who consider it "just a day job".
Even if you don't know the answer to a specific question it is worth mentioning that normally you'd look up the answer on < your favourite resource > (eg. StackOverflow).
Based on your experience I don't think the interviewer will expect that you'll get every question right. They're most likely trying to decide if you've got "potential".
So relax and try to enjoy it!
Besides the obvious parts of the language, I've found that employers will want to see if you fully understand pointers, references, how copy-constructors come into everything, probably STL, and of course the basics of classes.
Read (or skim, depending on how much time you have to prepare) "Large-Scale C++ Software Design" by John Lakos. Chances are, you will need it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I know C and C++ quite well. I know in much detail about pointers and well versed with pointer arithmetic and worked on Win32 API and a bit of MFC as well in my university days. In my previous job, I had no chance to look on these matters and worked in some other domain. Now what I want is a crash or refresher course in:
C++
STL
I do not want to go through 500+ pages of books because I know C#, Java, Ruby, Python and even x86 Assembly as well. What I want is to cover advanced and dark corners of C++ and intermediate STL.
Can anyone point out good links about it?
I know about Google! ;-)
But an intelligent human recommendation is something else yet Google has not implemented.
SGI has a pretty nice reference for STL.
As sort of a path to a deeper understanding of the STL you may want to take the time and watch some of the videos at http://www.stepanovpapers.com/. Also "Notes on Programming" http://www.stepanovpapers.com/notes.pdf will also help you understand the "Why" behind the design of the STL.
I'm not quite sure what you mean exactly by advanced C++ and intermediate STL.
The C++ FAQ Lite helped me a lot when I first started with C++.
www.cplusplus.com I like this site a lot
A quick read through of one or more of the 'Effective' books by Meyers and/or the 'Exceptional' books by Sutter would make a nice refresher course. They're short and generally easy reads for someone who's not a novice, but they'll refresh your memory on some of the edge cases you need to know about.
Read STL - C++ feeds on stackoverflow =)
comp.lang.c++
comp.lang.c++.moderated news groups
Herb Sutter's "Guru of the week" - http://gotw.ca/gotw/index.htm
Start learn boost (boost.org), it will be good way to refresh c++ and stl.
C++ Coding Standards : 101 Rules, Guidelines, and Best Practices (C++ in Depth Series) - small and easy for reading in subway book. It helps you refresh your knowledges.
Other books from "C++ in Depth Series" nice too.
For me, the best book on the STL is "Generic Programming and the STL" by Matthew H. Austern. It explains the STL very well from a conceptual point of view, rather then being a reference or tutorial on how to use it.
Some YouTube videos to refresh memory:
STL vector part 1
STL list part 1
I faced the exact same problem about 4 years ago. Moving from a java role back to c++.
The most useful book I found was "Effective STL" - Scott Meyers. This explains how to use the stl properly once your head gets around this your other C++ knowledge will come flooding back.
If you are struggling or still unsure of all the intricess of c++ after this read "Effective C++" and "More Effective C++" by the same author. All the Effective books are short and concise.
Also I always have Stroustrup's book on my desk, And I dip into it as I need to.