You think you know C++ ? Try this quiz !

Probably because I’m currently going through some job interviews, I wasted some time today trying a few C++ quizzes. I thought I had a good knowledge of C++. Not a Bjarne Stroustrup level knowledge, but a solid one, resulting from several years developing C++ server applications. Oh man ! My ego took a hit.

My favourite quizz was this one : http://www.mycppquiz.com/. I answered something like 30 questions, and failed maybe 2/3 of them… Nothing to be proud of. At least, I learnt a few things about a language I thought I mastered.

This was fun, but I still wonder how useful this kind of test is during an interview process. Unless you’re hiring a C++ compiler developer, which has to know the ins and outs of the C++ standard to write a compliant compiler, most of these questions are about C++ details that you don’t want to use in real world programs. For example, you don’t want to write such code :

const int x = 5;
 int main(int argc, char** argv)
{
int x[x];
 int y = sizeof(x) / sizeof(int);
 return 0;
}

Ok, you’ll be proud to know that global variable hiding doesn’t happen before the end of declaration, hence the x local array size initializer won’t be undefined. However, I’m not sure the next developer (me, 10 minutes ago) will know it. And you don’t want to write code that others will understand only if they have the C++ standard at hand, or know it by heart. You want to write code as simple as possible, that any average developer can easily understand and maintain. Bjarne is (probably) not your reviewer. You want code that doesn’t force the reader to focus on details, but that will as much as possible keep him at the level of the problem you’re trying to solve. But I guess this is much harder to measure with a job interview quiz..

2 thoughts on “You think you know C++ ? Try this quiz !

  1. philippe boulerne

    Bjarne is coming next month (october) in Montreal next door from you. Interested to meet him in person ?

    Reply
    1. Nicolas Riousset Post author

      I would definitely be interested in meeting him in person (even though I believe I would blush like a young girl, not really knowing what to say, afraid of looking dumb 😉 Unfortunately, I’m not in Montreal anymore. Maybe another time.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *