What question should be asked to test the interview candidate's knowledge of references in C++?
c++
Solution
in my book 7/10 means very competent. and 9/10 means someone who can do generative programming targeting c++ or template meta programming and 10 is people who write portable libraries. I do not believe in trick questions - only broad knowledge. So, here is the questions I would ask.
- What does it mean for code to be exception safe.
- What are the differences and pitfalls between the is-a relationship and the has-a relationship.
- Why should pointers be used if array entries are polymorphic.
- what is the difference between std::vector and std::deque.
- What is std::map good for ?
- What is RAII or what strategy do you use to prevent resource leaks.
- Why would you declare a destructor virtual ?
- What does it mean to provide a partial template specialization ?
- What is a functor ?
- what does the mutable keyword do and what does it mean for a function to be declared with const at the end of the signature.
- Why do you override compiler generated functions.
- what does it mean to bind variables to a function in STL vocabulary.
- Why is it a good idea to use std::string over the C functions.
- Do you know of any good c++ libraries, what is special about them ?
- what strategies do you use to ensure code is portable.
- What can you - as an application programmer * do with templates ?
- Can C++ stl containers create a performance bottleneck, give me an example.
- Is there a specific scenario you can think of that would require custom memory allocation.
- What are smart pointers, are they smart ?
- What is the pimpl idiom / compiler firewall, or how do you ensure short compile times across dependencies.
- Why are exceptions from destructors bad ? can you think of a way to get arround this issue.
- What is heap allocation and what is stack allocation.... is calloc evil ?
- What are cyclic dependencies and you can you tell me of one or more ways it complicates c++ programming.
- What is RTTI ?
- can you think of any runtime machinery (e.g., the exception mechanism) that would make your life easier ?
- Java and C# are considered amazing languages. What project should be written in C++ ?
- What are your opinions on multiple inheritance ?
- Can you think of a reason to use the preprocessor ?
- what are the benifits of declaring variables const ?
- What tools do you use to develop ?
Could go on for ages :D but 30 will do , if you need more just ask :D
Problem
If a candidate says that his knowledge in C++ is 7/10 and you want to test his knowledge of references in C++, what question will you ask? I thought of the following: - Write a function declaration that takes a pointer as reference with default values and ask him to figure out a mistake and explain it. - Pass a literal as argument to a function that takes that parameter as reference. Any other question that is better at testing candidates overall knowledge of references in C++? Thanks,