views:

2243

answers:

4

Curious to get people's thoughts. I conduct frequent interviews, and have had enough in my career to reflect on them, and I've noticed a broad array of questions. I made this c++ specific, but it's worth noting that I have had people ask me algorithmic complexity questions over the phone, and I don't even mean what is the complexity of a hash lookup vs. a binary tree, I mean more like analytical problems, such as "imagine there are 4 bumble bees, each buzzing bla bla bla."

Now personally I prefer to keep phone screens a little more concrete, and leave the abstract questions for the white board. So when conducting c++ phone interviews, what kind of topics do you cover, especially for Sr. developers?

I know there is another thread similar to this, but frankly it seems to completely have missed the point that this is about phone screens, not interviews that are face to face. Plus this is more c++ specific.

+4  A: 

I like to find out if people actually know anything about the tools they're using. And I also find that "senior" developers can have serious gaps in their knowledge.

You could consider asking

  • What a vtable is.
  • How templates work
  • What the difference between the heap and the stack is. The depth of the reply to this one could be quite illuminating!

The "you really need to interview me" answer to the last question would cover

  • allocation - limits, use-cases, failure modes, efficiency, resource cleanup, destructors
  • stack call-frames - what happens when a function is called, parameters, backtraces
Airsource Ltd
Definitely like the heap/stack question. You can spend a fair amount of time discussing that.
ApplePieIsGood
True, heap/stack is a good question. Brings up heap vs stack *allocation* as well, and the different semantics for those (stack objects go out of scope, destructor gets called and so on)
jalf
Although beware of selecting candidates according to how well-prepared for the question they are, rather than how well they know the technical details. A reasonable initial response to "what are the differences between heap and stack", is "hang on a second, what are the *similarities*"?
Steve Jessop
+7  A: 

I'd ask about resource/memory management, because it's an important subject in C++, and it doesn't require concrete code. Just sketch a simple hypothetical scenario, and ask how they'd ensure some vital resource gets freed even in the face of errors/exceptions. Say they're developing a network app, how do they ensure that we close our sockets properly? Of course the proper answer would be to wrap it in a RAII object, but don't ask them that directly (it's easy to google "RAII", while the above question "how would you ensure resources get released properly" actually shows you whether or not they know the appropriate techniques. If they answer "wrap everything in try/catch", they might have a problem. And this ties in nicely with questions about the differences between heap and stack.

You might be able to come up with some simple question about exception safety too, which doesn't require any real code. In general, I'd say a discussion of all the various C++ idioms might be a good idea, because many of them don't require much actual code, but are still vital language-specific concepts.

See if they know about smart pointers (again preferably by giving them a situation where smart pointers are called for, and see how they would solve the problem), and maybe templates/metaprogrammin (in the latter case, probably just find out if they're aware that it's possible ,rather than requiring them to code actual metaprograms on the phone)

You might also want to ask about some common areas of undefined behavior (what are the values of a and b after executing a = b++ + b++??), or allocate an array of 10 elements, and add 10 or 11 to the array pointer, and ask what the result is in each case (+=10 is legal, gives you a past-the-end pointer, +=11 is undefined). Or give them a scenario where they need to copy a lot of objects, and ask how they'd do that (plain for-loop copying each element at a time, memcpy or std::copy are obvious answers. Note the caveats with memcpy, that it's not safe for non-POD objects)

Or ask about their coding style in general. How do they feel about iterators? Do they prefer plain old for-loops? Do they know how to use std::for_each or std::transform?

Edit: Seems the a = b++ + b++ (the answer is undefined behavior, btw) suggestion in particular generated a lot of comments. Perhaps people read too much into it. As the OP said he preferred to ask concrete (not abstract, and easy to explain/answer/discuss over the phone) questions, that'd reveal a bit about the interviewee's C++ skills, and this is a simple (and yes, perhaps nitpicky) example of that. The reasoning behind it is that 1) it has an intuitive meaning, which is wrong, and 2) you have to have a certain level of experience with C++ before you realize this. And of course 3), it's short and easy to ask over the phone. It doesn't require anyone to write code down. No, it won't reveal whether the candidate is a "great programmer", but as I understood the question, that wasn't the goal either. If someone gets it wrong, it doesn't mean much at all, but if they get it right, you can be fairly sure that they know a bit of C++. But if you read my answer again, you'll see that it was just a quick example of a category of questions I thought should be represented. C++ is full of undefined behavior, even in code that looks completely harmless and intuitive. Asking the candidate to recognize some instance of this may be useful, whether it's the "modify the same variable twice in the same expression" example above, or something different.

jalf
Re for_each and transform: I know some coders who avoid it because they feel that making a functor class is too clunky. With C++0x closures (or Boost.Lambda, though that was rather new technology back when I was having this discussion), that situation would be much, much improved.
Chris Jester-Young
I guess part of the phone screen could be about whether they mention Boost.Lambda or closures! :-P
Chris Jester-Young
This is probably not one of those questions that you get one perfect answer to, but I like yours a lot, it deals with the difficulty of coding over the phone.
ApplePieIsGood
I think we should avoid asking a = b++ + b++ types of questions
Vinay
Perhaps. It's just an example of things that don't require much code, and which isn't as easy as it looks. And which will most definitely blow up in your face if you rely on any specific behavior.
jalf
Frankly, I'm not sure if I would tolerate an "a = b++ + b++" question on a _phone screen_. Maybe I'd think "let's find a sensible company".
Daniel Daranas
Agreed, I would laugh at the interviewer if he tried to ask me a question about "a = b++ + b++" over the phone. Perfectly good in person interview question though.
Greg Rogers
I agree, a= b++ + b++ is a nitpicker question. There is no relation between knowing the answer to this question and being a great programmer.
Edouard A.
Nope, of course there isn't. But it's a way to probe people's knowledge of C++. If they know that it results in undefined behavior, then it's a sign that they've spent enough time with C++ to know that it's not as intuitive as it looks.
jalf
The proper answer to a=b++ + b++ is "you should never write code like that". whether it is defined or not, you just shouldn't do it.
Kip
That's a valid answer too, of course. ;)
jalf
+1  A: 
  • Design Patterns
  • Basics of C/C++
  • Virtual Functions
  • Poly morphism
  • Concepts from Scott Mayer's series
  • About templates. (Not in particular order)

Last but not the least. I will give some sample problem I tell them to design the classes. Just the interfaces.

Vinay
I don't get your ordering here. Aren't design patterns the most "high level" point in your list, and "basics of C" the most "low level"?
Svante
OK, I see the "not in particular order" now, but doesn't this contradict your first sentence and the apparent numbering?
Svante
Last but not least is probably just a saying as he's listing it from his head, not in order that he asks the questions.
ApplePieIsGood
A: 

As part of a phone screen for C++ positions I've taken to asking 'Who is Bjarne Stroustrup".

I find it amazing that many many people claiming to be be senior C++ devs can't identify. Hint for English speakers: Go to his FAQ and listen to the correct pronunciation before you ask the question.

Jim In Texas