views:

643

answers:

3

What interview questions should people expect as a junior C and C++ developer? Code questions or more of theory? Solutions in pseudo-code or in C code?

Maybe I'm misinterpreting the word "junior", but I have no idea what would anyone ask me if I have no C work experiences. I'm bit afraid of tricky questions with pointers, so I'd like to be sure what should I look up before actually going there.

+13  A: 

I don't mean to sound harsh, but if you would find pointer questions "tricky" maybe you should do some studying and use of the language on your own before pursuing a job in it. Do a side project or two, brush up on the language, then worry about the interview. "Acing" the interview should come from the fact that you really know what you're doing, not that you quickly brushed up on the "tricky parts" beforehand.

Bob Somers
Perhaps I misunderstood, but even for non junior programmers there are "tricky" aspects of pointers. While I expect a junior C++ developer to know the basics of pointers, most C++ developers I know could not tell you why the following two lines of code are illegal.char* x;const char** y = I would not expect a junior C++ developer to explain this to me, or know the syntax of pointers to member functions or data members.
Stephen Nutt
+4  A: 

If you're a PHP dev with 1 year's experience you'd better get reading and practicing with some code.

You will need to know about pointers, you will need to know the basic object creation/destruction process and the differences and relative merits of stack vs heap allocation.

Fundamentally you will need to understand the core differences between a dynamically typed, interpreted language like PHP vs a statically typed, compiled/linked language like C++.

Paolo
+7  A: 

At my company, I would approach the interview in close the the same way as we do the interviews for interns from the local university... which is to say, we ask a lot of questions looking to find out what they actually know about the language.

We would ask for things like definitions of the following terms (the last two we wouldn't usually expect junior programmers to know; bonus points if you do):

  • static
  • const
  • protected
  • friend
  • virtual
  • mutable
  • explicit
  • volatile

We would also ask about some programming concepts:

  • What is a memory leak?
  • What is a mutex?
  • What is a deadlock (and how might you prevent one)?

We would ask at least one general programming competence questions:

  • In the language of your choice, write a short program that outputs odd numbers between 0 and 100.

We would ask some C or C++-specific questions:

  • In C++, write an assignment operator for a String class.
  • In C or C++, write an infinite loop construct.
  • In C, write a MIN #define that takes two arguments and returns the smaller.
  • in C++, write a min function that takes two arguments and returns the smaller.

We might also ask some other thinking-type questions:

  • For the function int* sort( int* data, int size ); what are some inputs you would give it to determine if it works correctly?
  • If you are designing a card game for (random card game, like poker), what sort of data structures might you use. How would they interact?

We might also ask some trickier questions, based on how well the interview goes, but we wouldn't expect a junior programmer to answer them. Depending on the question, they might be expected to provide an indication of how they would research it. For interns, we are looking for at least a little understanding of the terms and concepts, and stronger answers on the other questions. For a junior developer, if they listed C or C++ experience, we would expect most of the keywords to be answerable, as well as most of the other questions I mentioned. For a more experienced developer, we'd expect nearly all of the questions to be answered, and we would likely press them for more than just the surface answers (such as "Can you think of a time when declaring a variable both const and volatile might be useful?")

Caleb Huitt - cjhuitt
` write a MIN #define`: You mean a preprocessor macro, right? (maybe i misunderstood something)
Tom
I'm a fairly experienced C/C++ developer and i had never come across explicit until I got asked about it in an interview recently. And the only time in 15years of development I have needed the volatile keyword - the compiler was buggy and didn't make it volatile!
Martin Beckett
You need the volatile keyword a lot more frequently in embedded systems work.
Bob Somers
@Tom: Yes, I mean a macro. The question was changed to "write a #define that..." instead of "write a macro that..." due to too many intern candidates and junior level candidates not knowing what a macro was until we explained "It starts with #define".
Caleb Huitt - cjhuitt
@Martin: I didn't know about explicit or use it until my current position... but after learning about it, it would have helped in at least once case in my previous position. There are certainly a few times it's helped us.
Caleb Huitt - cjhuitt
@Bob: That's true, and one reason we include it (especially for more experienced developers) is that part of our group does embedded work. Also, it can be important in certain threading contexts, although we usually wrap those in mutexes.
Caleb Huitt - cjhuitt