- What is boost? And why is it useful? - What is a shared pointer? - What is the difference between shared pointer, auto pointer and intrusive pointer? - How is shared pointer implemented internally? - How would you convert from string to integer using boost?
#include #include #include
/* Implement as simple a class as possible to pass the test case below. If possible, - use only a single container - do not use a void pointer - use any stl/boost/mpl algorithms that are of use */
I have been interviewing for a C++ software developer position at some of the UK finest investment banks and hedge funds. Here I'll share some of the questions that I was asked in a series of posts. But to be fair, I won't mention the names of those companies.
Those are actual questions I have been asked:
1- When would you prefer passing a reference to a function than a pointer? 2- Where is the const keyword used in C++ and what does it mean in each of those places it is used? 3- What is a mutable variable? Why might we need one? 4- What is a dynamic cast? What is RTTI? 5- What is an exception? When would you use exceptions? And why are they better than retyrning error codes? 6- How are exceptions implemented in C++? 7- How can a function guarantee that its resouces are released if an exception is thrown in the middle? -- Use RAII. 8- What is an exception safe function? What are the three types of exception safety? 9- What is a dangling pointer? And how does it usually happen? 10- What is a memory leak? How would you go about fixing it? 11- What is polymorphism? Virtual functions? Virtual tables? 12- When do you need a virtual destructor? Why is it not a good idea to always use virtual destructors? 13- Why is it a bad idea to throw exceptions from a destructor? 14- What is a pure virutal function? Why might we need to use it? 15- When do we absolutely need a dynamic cast? What alternatives can we have to dynamic casts? 16- Can pure virtual functions have an implementation? Is it a good idea to give them default implementation? Why? 17- What is a design pattern? 18- Explain Observer, Singleton and Bridge design pattern? 19- What is an Agile development? 20- Why do we need operator overloading? What concerns might we have with overloading? 21- Assume we have four istances of the same class, A, B, C, and D. What is the minimum number of operators called for this operation A = B * C + D? 22- Which could be potentially faster: accessing elements of a 2D array column-wise or row-wise? i.e., traversing columns or rows? 23- How do you prevent an object from being copyable? When might you need to do that? And in this case, how do you prevent methods of this object from calling its copying functions? What errors might arise? 24- How does C++ name mangling work? 26- How is polymorphism implemented in C++? 27- Can we have static virtual methods? Why? ....