share
Stack OverflowI need to improve my C++ skills, fast, is this realistically possible?
[+15] [15] nbolton
[2009-08-04 14:11:50]
[ c++ self-improvement ]
[ http://stackoverflow.com/questions/1227764/i-need-to-improve-my-c-skills-fast-is-this-realistically-possible ] [DELETED]

After taking a very hard C++ aptitude test for a blue chip company, I received a rejection email the day after. I actually thought I was a very good C++ programmer, since I have had 8 years previous experience with other languages, and about 2 years academic experience in C++ with a university software engineering course. So, the test results brought me back down to earth a touch.

I'm working on some C++ open source projects, but I feel this could take a while before it gets me up to an advanced level of C++. Since I'm applying for C++ jobs at the moment, I'm afraid that there will be many more rejection letters to come.

To the point, is it possible to self-learn advanced C++ knowledge quickly (i.e. in a few months), or will I have to accept the hard truth that this is going to take me years?

Is there a UK-based "code camp" or something like that? Perhaps there are some industry standard C++ qualifications I can take?

... I'm a very hands-on learner like most people, so I'm worried that the 'buy a book' route won't work for a quick turnaround... By the way, I'm not working right now, so I'm free to spend all day learning.

Update 1

Here's some of the questions they asked (that I vaguely remember). I would post some of the harder questions, but, well, if I could do that then I probably wouldn't be asking this question! :)

If you are creating a template, similar to Map<T>, but wanted to define an order type, where would this functionality be placed?

Well, just remembering that off the top of my head, so I probably phrased it totally wrong. There were 4 multiple choice questions that I'm not even going to attempt to remember.

In the code sample provided, in what order are the constructors called?

Now, this is one of the easy ones. In the code sample featured, there was a number of class definitions and some virtual inheritance mixed in there. So I guess the test here was, "in what order are virtual class constructors called?" I mean, this is possible to find out by just typing some sample code, but with 3 minutes on the timer, this was apparently quite tricky.

In the code sample provided, what should the type x be?

Again, one of the "easy" ones, but not for me. In this one, they had an operator overload for negation (!), so it looked something like:

x operator!();

I can't remember what the multiple choice questions were, but I think one of them was bool, but another was "you can't overload !". A bit of searching will reveal the answer, but again, with 3 minutes on the clock, this wasn't so easy since searching for "C++ operator overload list" didn't reveal any quick reference lists.

Update 2

I didn't say I wasn't willing to learn from books; I actually have a ton of books, and they've helped a lot - the problem is that it takes a long time to really learn the content.

If books are my only option, then so be it. But if anyone knows a faster way, please share it... Are C++ courses [1] worth the money?

Do you know where you went wrong in the test? - Goz
(1) what did the rejection letter say? That you did not pass the aptitude test? Maybe there were other reasons. I have experienced that a lot of interviews in UK are just for show in order to meet legal requirements, while they already have someone "in mind" for the job. Also, a good aptitude test will test for fundamental understanding, not details. You have not really explained what the test was testing. - txwikinger
If I may ask, what section of the test did you find the most difficult? - Max
Sorry for the rude awakening. Those are disappointing, I know. Do you recall any of the test questions, especially those you were less sure of the answers? That might help you focus on specific areas to strengthen, or help people here give targeted answers. - kajaco
(1) I find this question particularly confusing, because you say you "thought [you were] a very good C++ programmer." Presumably, you know what skills you have and which you apparently lack; however, you haven't told us. So how could we have a better idea than you about whether you can learn them a few months? - mquander
txwikinger, Max, kajaco: I will post some sample questions. mquander: To be honest, I'm not sure I know the language well enough to know in what areas I lack. I think probably terminology is a big area in which I suffer, as is the case with most self-learners. - nbolton
(6) You get rejection letters? Here we just know when the phone doesn't ring :( - Tom
(1) @mquander: There might be a Dunning-Kruger effect, you never know. - txwikinger
Was it 3 minutes for each question? Or for all the questions? And you had internet access while doing the test (an 'open book' test)? - Jonathan Leffler
Jonathan Leffler, 3 mins per question, about 50 questions. Yes, I had internet access and a compiler; had I not had those tools, I would have done considerably worse. - nbolton
txwikinger, I think you might be spot on there. Before, I would have rated my self a 7/10 since I was too incompetent to see my own mistakes, but now that I see how good (or not so good) I actually am, I might rate my self a 3 or a 4 out of 10. - nbolton
@Nick: Well.. it is always good to learn something. I would think almost every body has fallen in the trap of the Dunning-Kruger effect more often than they would admit. The good thing, you see now where your deficits are and can do something about it. - txwikinger
You think you are a good C++ programmer until you start doing it full time, then you realise you have a lot to learn. But don't lose heart, interviews are mostly random luck :-) - Chris Huang-Leaver
[+27] [2009-08-04 14:19:44] RC. [ACCEPTED]

I would suggest the following books:

Exceptional C++ - Herb Sutter [1]

Effective C++ - Scott Meyers [2]

More EffectiveC++ - Scott Meyers [3]

Modern C++Design - Andrei Alexandrescu [4]

Whether you are able to quickly learn anything depends largely on you and your work ethic.

[1] http://rads.stackoverflow.com/amzn/click/0201615622
[2] http://rads.stackoverflow.com/amzn/click/0321334876
[3] http://rads.stackoverflow.com/amzn/click/020163371X
[4] http://rads.stackoverflow.com/amzn/click/0201704315

Great selection. - Max
+1 for the Meyers books, they're really very good. - Ed Woodcock
+1 for the Alexandrescu book, but you should definitely read this after the others. - Salgar
Once you're suggesting books even though he said he wouldn't want to read (BTW; how can one write software without reading books?) I'd definitely add Konig/Moo excellent book (amazon.co.uk/dp/020170353X) even though he rejected that, too. I read it after 10 years of C++ including some tampering with TMP (I really read it for for a review, because I was teaching C++ then) and I enjoyed it a lot, even though the "only" thing it taught me back then was a new look at C++ as a high-level language. - sbi
(3) All the questions he mentioned should be answerable by someone who has read TC++PL - and if you haven't read that, you are definitely not an experienced C++ programmer. - anon
@Nick Yes indeedy. So I take it you haven't read it? That's a bit like C programmer not having read K&R. - anon
@Neil, I will buy this right away! @sbi, Please see update #2 :) - nbolton
@Nick: "Accelerated C++" is only 250 pages. :o> - sbi
1
[+4] [2009-08-04 14:30:08] anon

about 2 years academic experience in C++ with a university software engineering course.

when interviewing, I personally don't count any academic course as experience. As an ex-instructor, I know how little these things can actually impart. You don't say what level of experience the job you went for required, but at the end of the day there is no substitute for reading the classic books on C++ and gaining real experience on real projects.

Edit: Regarding your question on C++ courses. As an ex-instructor on (and writer of) such things, I would of course say yes. But in all honesty, they won't offer too much apart from the basic syntax and concepts, which I assume you already have. You will probably be much better off spending your time and money on a couple of good books and sitting down to write some code.

Of course, courses can be useful for very specific purposes, such as learing COM or sockets programming for example. Though I do remember being a bit disapointed in our own Windows programming course when I sat in on it for the first time - "So you just send messages to everything?" was my comment after the first hour, and I didn't bother much with the rest of it.


(1) Hmm, well to me it seemed advanced, but then again there were a fair few very easy questions. The job description is "entry level C++ programmer", so to a C++ veteran, I guess the level would be easy, but to an apparent C++ newbie, it's hard. - nbolton
(5) Well, C++ is hard. - sbi
(1) @sbi actually, I don't think it is. I used to train people in it, and most people I trained at the end of the course said it was easier than learning C. Of course, there is now a big library to learn (which itself makes things easier). And I don't hear java or Python people complaining about library size. And there is lots of stuff you needn't get into like TMP - I'd expect an experienced programmer to know what TMP was, but not to be able to do it to any great extent. - anon
A test for an "entry level C++ programmer" had questions like you gave? They're nuts! - kajaco
I suspect the OP said he WAS experienced, and they give him the test based on that. - anon
@Neil: I, too, have taught C++ for many years. IMO, coming from Java, C# or whatever, C++ is pretty hard. It's disturbingly huge, complicated, full of compromises and legacy decisions. You need to tell references from objects and pointers, it has three different operators where other languages just use a ., you need to decide when member functions and base classes should be virtual, remembering the order-of-initialization rules in presence of MI and virtual bases is a daunting task, not to speak of exception safety. - sbi
Hmm, my CV says along the lines, "I'm an experienced programmer in x y and z, with 2 years academic C++ experience." ... It felt like that test was above the level of your average graduate programmer, so maybe they were looking for an exceptional C++ graduate? - nbolton
Ah, actually, come to think of it, there was a question on the application along the lines of C++ competency. There were 4 options; no experience, some experience, intermediate, and advanced. I chose intermediate... May be I should choose "some experience" next time? - nbolton
(1) @sbi I suppose my advantage was I wasn't teaching to Java programmers :-) - anon
2
[+4] [2009-08-04 16:51:18] jalf

In addition to all the already mentioned things (good books, courses, participation in open-source projects and all that), here are a few things that might also help:

A very simple trick might be to subscribe to the RSS feed for C++ questions here on SO.

A wide range of questions get answered here, on every difficulty level, and they generally get very detailed answers.

It won't replace a good book on C++ of course, but it might be a good way to discover a wide range of concepts, pitfalls and solutions you might not have known about otherwise.

And get a copy of the C++ standard, and get used to cross-referencing it when you're in doubt about whether or not some code is legal. It's not an easy read, but in teaching yourself to find the information you need in it, you'll automatically familiarize yourself with a lot of the rules of the language that the compiler won't tell you about or enforce.

One of the most important things to realize when coming from another language is that you have to be a bit of a language lawyer. A lot of C++ questions here on SO are so full of references to the standard, it's almost funny. No one trusts an answer if it isn't based on the standard. "It worked when I tested it on my compiler" doesn't carry any weight.

In most other languages, you can usually get away with just experimenting and seeing what is accepted by the compiler, or what seems to work when you run it. But that won't cut it in C++ land.


If you just experiment, you're likely to stumble into unspecified, implementation-defined, or just plain undefined behavior, cases in which two different implementations might do different things and both be right. Compiler writers, in general, don't care what the compilers do in these circumstances, and won't try to keep it consistent. An experiment will tell you what happened in one case, not what will happen with another compiler, another version of the same compiler, different settings on the same compiler, or even with different surrounding code. - David Thornley
@David Um, I think that what jalf is saying, though I did have to read his last para twice to make sure :-) - anon
bah, I understood what I meant! ;) Tried to clarify a bit. - jalf
@jalf: Would you mind point me the way to subscribe to the RSS feed for C++ questions on SO? - pierr
Sure. I don't know which browser and/or RSS reader you use, so I'll just point you to the feed and hope you know how to subscribe to one when you see it. ;) Basically just go to the SO page for the C++ tag ( stackoverflow.com/questions/tagged/c%2b%2b ), and the feed is available from there. The direct link to the feed is stackoverflow.com/feeds/tag/c%2b%2b - jalf
3
[+3] [2009-08-04 14:21:41] David Menard

From my experience, c++ aptitude tests usually cover basic c++, and the more advance c++ stuff is company and library dependent, depending on the job you are applying to. I would suggest refreshing yourself with basic c++ books and tutorials before even trying to learn more advance stuff. But the only sure way of learning advance c++ is to practice it and start your own personnal projects. Find something that looks fun, and do it, no matter what your experience is.


4
[+3] [2009-08-04 14:23:34] Andrejs Cainikovs

Oh man.. I was in the same situation recently.

What I'm currently doing is small enthusiastic projects using WxWidgets (preferably converters, the are really handy in means of practice) and rewriting my old C libraries to C++. While doing this, I'm trying to use containers like vectors, maps, and so on. What is important is classes and structures, inheritance.
Also, some reading. One of the questions I had failed on was the difference between virtual and pure virtual. You know, in practice, you usually don't use this.

Hope this helps.


(8) i'll have to disagree, using pure virtual is very important, and that, again, is basic c++, not very advanced. It is crucial you know these things before you set out for a job interview. - David Menard
You are very right. The funny thing is that I don't remember using virtual at all during last few years. :-) - Andrejs Cainikovs
(1) Because you don't make abstract classes, I do :) - the_drow
(1) Meh. Pure virtual is only important if you are writing for other people to use your code. Otherwise you can just not use it non-purely. - Zan Lynx
5
[+3] [2009-08-04 15:38:43] Richard Corden

Some of these questions look similar to those found in BrainBench [1]. Every now and then the BB tests are free and you can take advantage to run though them a few times.

I would make a note of what the question is asking and then go to the standard to read up on the section involved.

Some of the questions require very close and careful study, in that they are almost like trick questions. I assume this is to sort the "best(tm)" people.

And finally, of course nobody is perfect, so there is always the chance that the answer you pick is correct, but the test doesn't agree!

[1] http://www.brainbench.com/

Ah, yes yes, it was a "Previsor" test, thanks for pointing that out! - nbolton
Richard, I've just purchased the "C++ Practice Test" and I'm doing it now, thanks for pointing me in that direction. These questions look almost identical :) - nbolton
(1) The BB tests are crap. I worked for an IB which bought a license for them. The IB's training department had to close the website because they were getting bombarded with posts from developers pointing out errors in the questions. - anon
@Neil: I wasn't "recommending" BB either way. The key benefit with them from the perspective of the Questioner is simply as pointers to the kind of edge cases of the standard that tests such as these use. C++ is a complex language and I'm not going to state either way that the questions are perfect. TBH, I have found in the past that the expected answer reflected the behaviour of specific compilers more than the text of the standard! - Richard Corden
I just registered at BrainBench, and the test are 50$. :-/ How do I find out when the test are for free? "Every now and then"? Do I have to have a look at the site every day/week? Or how do you find out? - AudioDroid
@AudioDroid: I'm unable to help you I'm afraid. Over the years I've taken the test a few times (I've never paid). My history shows I last took the test in 2009 and before that in 2008. - Richard Corden
6
[+2] [2009-08-04 16:04:42] leander

Remember articles! Short, sweet, and covering a ton:

Also, I can't recommend the C++ Coding Standards [5] book enough; not only is it a peek into the collective "common sense" of the C++ community, it also delves into some interesting corners of the language.

After that, keeping a subscription to the boost mailinglists [6] or other community sources can't hurt. You'll be surprised what you pick up by just keeping an ear to the ground -- even if some of the talk is occasionally above you.

[1] http://www.parashift.com/c++-faq-lite/
[2] http://www.research.att.com/~bs/bs%5Ffaq2.html
[3] http://www.research.att.com/~bs/bs%5Ffaq.html
[4] http://www.gotw.ca/gotw/
[5] http://www.gotw.ca/publications/c++cs.htm
[6] http://www.boost.org/community/groups.html

7
[+2] [2009-08-04 16:48:03] Eric J.

The key to improving ANYTHING quickly is immersion and mentoring.

You will need to commit to spending a large amount of time over the time you have available to learn about a new aspect of C++ that you don't already know, then WORKING with it.

Exercise books might help you do well on a test. They will not help you become a good C++ programmer (do you really want to get that job, then struggle to keep up?)

Find a project (maybe like previous poster, rewrite a C project you know well in C++; maybe find an open source project that is both in need of C++ and is good about providing mentoring to junior members).

Find a mentor or two (people you know; open source project members; ...)

Do nothing but work on your project, work with your mentors, eat and sleep for a few weeks (OK maybe a few other necessities of life too... but be DEDICATED to learning and improving).


8
[+1] [2009-08-04 16:20:02] jon-hanson

I've never found courses that useful. Maybe to get you started, but beyond that you rarely have the time in a course to go over more complex problems.

I think the only real way is actual development. I nearly always have a test project open in the background, which i use to quickly test some crazy coding technique, or try out a c++ question.

If nothing else offers itself then invent a small project with the sole purpose of using some advanced techniques. I'm writing a web app just to brush up some Java and learn a bit about REST, Spring JSP, JSTL etc.


9
[+1] [2009-08-04 16:31:20] dassouki

I found it helpful to buy a c++ excercise book with its solution manual.

I did most of the excercises myself, and then redid them according to their answer. I learned a lot that way.

Project Euler [1] really has some good and fun problems as well

[1] http://projecteuler.net

Would you mind sharing which book that was? - AudioDroid
10
[+1] [2009-08-04 19:51:23] Paul Nathan

Responding to your 4th edit....

You should invest in the "c++ standard books", ie, the standard itself, the exceptional books, the andrescu book. Then, read them and apply them. Motivate yourself to find some sort of project - either open source or one you've been wanting to do. Use Boost. Then finish the project. Keep doing this for maybe 10K-20K LoC. Keep improving your code quality as you go along.


11
[+1] [2009-08-05 05:18:32] sourabh jaiswal

I would suggest to go through the following :-

1.Read Modern C++ Design by Alexandrascu Andrei for understanding templates and metaprogramming in details.

2.Read Inside the C++ Object Model for gaining insight on the C++ object internals(inheritance, virtual inheritance, cast etc)

3.Read Effective C++, More Effective C++ for other non trivial C++ stuff.

4.Read GOF Design patterns book.

5.Try to implement a compiler for an educational OOP language such as Decaf or COOL.


12
[+1] [2009-08-14 12:17:08] zooropa

Check out the book Programming Interviews Exposed. I think that is a good resource that lists a lot of programming topics that you should know.


Nice suggestion! - nbolton
Ha, on the UK Amazon site, one of the comments said, "I actually interviewed at Microsoft earlier this year and the person who interviewed me had this book with them!" - I clicked 'buy' immediately after reading this. - nbolton
13
[0] [2009-08-04 16:07:23] A. L. Flanagan

The answer depends on your learning style. C++ classes might be beneficial, if a) they're sufficiently advanced, and b) you learn better in a classroom setting. The last is very important, some people just learn better from other people rather than books.

My recommendation for learning C++ is "Thinking In C++". You can get an electronic copy at Bruce Eckel's web site [1]. (No I'm not connected to author or site).

[1] http://www.bruceeckel.com

14
[0] [2011-06-24 14:53:39] AudioDroid

I can recommend the tutorials at www.topcoder.com. Also Google suggests this site for people that think of applying for a software developer/engineer position at their company.


15