45

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??

Kyle Walsh
  • 2,774
  • 4
  • 27
  • 25
Light_handle
  • 3,947
  • 7
  • 29
  • 25
  • 36
    If you're going to use Google during the phone interview, get a quiet keyboard ;-) ... someone I was screening last week is the reason for that tidbit. – Eric J. Oct 15 '09 at 01:02
  • 1
    Make sure you are sitting in a quite room and also inform your friends not to disturb you during iw. – Duleb Oct 15 '09 at 12:18
  • 2
    You can try and have a real C++ test here http://www.codelect.net/TestDetails/Cplusplus%20test%20for%20Seniors – Uri Lukach Mar 28 '13 at 07:40

8 Answers8

58

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:

Now, for completion's sake, some books:

Kyle Walsh
  • 2,774
  • 4
  • 27
  • 25
  • 1
    Also check out this blog post on keeping C++ declarations straight, just in case they try and trip you up with those: http://binglongx.spaces.live.com/blog/cns!142CBF6D49079DE8!273.entry – Kyle Walsh Oct 15 '09 at 01:16
  • 1
    A couple of the sites you link have information and/or code that is just outright wrong. I'm not sure why this is the accepted or most-voted-for answer. – codetaku Mar 13 '14 at 01:54
  • @codetaku Well, the questions linked themselves are the value. Going through the practice of answering them will give the most benefit. That said, if you wouldn't mind pointing out the offensive content we can update the answer so other people are not led astray. – Kyle Walsh Mar 25 '14 at 05:21
56

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.

Matt
  • 10,434
  • 1
  • 36
  • 45
  • 13
    +1 because I learned a few things. Thanks! – John Oct 15 '09 at 01:39
  • 4
    Just out of curiosity... why would you prefer `boost::shared_ptr` over `std::auto_ptr` without more information? I would be much happier with a candidate that responded with _"it depends on what is in [do some stuff]"_ myself. – D.Shawley Oct 15 '09 at 03:03
  • 4
    Indeed. If the `auto_ptr` would do but you wanted to avoid its pitfalls, one would use `boost::scoped_ptr` (or `std::tr1::unique_ptr`). – UncleBens Oct 15 '09 at 09:12
  • 2
    std::auto_ptr is not copyable - if you try to pass it by value to another function, that function will _take ownership_ of the pointee and, since arguments go out of scope at the end of the function call, free it then. Probably not what you had in mind. This is because auto_ptr only takes a pointer in new and guarantees deletion when out of scope. Boost's shared_ptr can be copied, as it maintains an internal reference count, so passing it by value into a function does "what you expect" by incrementing the reference count. Only when the count goes to 0 does it free the pointee. – Matt Oct 20 '09 at 06:50
  • 1
    This is also why the scoped ptr is great - it can't be copied, period. While the auto_ptr has "transfer of ownership" copy semantics, scoped_ptr has "this code doesn't compile" copy semantics. Much harder to use unintuitively. Kudos to UncleBens for that. – Matt Oct 20 '09 at 06:52
  • 1
    @Matt in C++ 11 is the answer changed? what does it mean by "+7 for talking about garbage collection techniques to fix circular references"? – athos Jan 07 '15 at 16:09
8
  • 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.

theycallmemorty
  • 12,515
  • 14
  • 51
  • 71
4

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.

Pedro Estrada
  • 549
  • 3
  • 9
3

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!

Void - Othman
  • 3,441
  • 18
  • 18
3

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!

Richard Corden
  • 21,389
  • 8
  • 58
  • 85
2

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.

Smashery
  • 57,848
  • 30
  • 97
  • 128
1

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.

Max A.
  • 4,842
  • 6
  • 29
  • 27