Test your C++ knowledge

C++ is certainly not one of the simplest languages to learn. While it is possible to make quite high-level, yet fast and memory-efficient, code with it, this does not come without its drawbacks. There are many things one just has to know about C++ in order to not to "shoot oneself in the foot".

So, how well do you think you know C++?

This test is by no means comprehensive nor necessarily accurate, but it may give you some idea about your C++ experience. Read the instructions carefully before you proceed.

The test

A link is given below to a piece of C++ code. This code declares and implements a small class. After you follow the link and look at the code, can you answer these questions?

  1. What is the class supposed to do?
  2. There's a major problem in the implementation of the class. Can you spot it?
  3. Can you give 4 different ways of fixing this problem (depending on the requirement specifications of that class)?

If you can answer questions 1 and 2 in less than 30 seconds and you know all the four fixes in question 3, then you are very experienced in C++.

If you can answer questions 1 and 2 in less than 2 minutes and you know at least 2 fixes, then you have a very good knowledge of C++.

If even after 2 minutes you still don't know the answer to question 2 (that is, the correct answer, which is given below) then you still have much to learn about C++.

Here is the code.

The answers

I have written the answers in a separate page.