In this post, I’ll share commonly asked interview questions of C++ language. Most of us start our programming journey with C++ mainly because of CP. The downside is that we say C++ is our preferred language but for CP we barely need any core concepts of the language, apart from basic syntax and usage of STL. But in the interviews you can expect in depth questions and you must be prepared. From my personal experiences, I have prepared this list of questions that are commonly asked. Note that this list is not exhaustive and there are many more things in C++ to learn.
Questions
- What is compiler, linker, loader?
- What are preprocessor directives?
- What is namespace?
- What is the memory layout of a C++ program?
- What is a static variable?
- Static vs Global?
- Macros vs Functions?
- What is an inline function?
- What is template in C++?
- What is a pointer?
- Pointers vs references?
- Dangling, wild, null pointers?
- Void pointer?
- What are smart pointers?
- What is a class/object?
- Struct vs Class?
- Size of struct and class, empty class, class with only functions, padding?
- What are access modifiers?
- What are constructor, destructor?
- Copy constructor?
- Shallow vs deep copy?
- this pointer?
- static class member?
- What is operator overloading?
- friend classes and functions?
- new and delete operators? replacing global new and delete?
- What is inheritance in C++, public vs private inheritance?
- What is polymorphism in C++, compile vs runtime poymorphism?
- Virtual functions? what if we don’t make function virtual?
- What is vtable and vptr? Size of a class with virtual functions?
- Virtual destructor and its use case? Can constructor be virtual?
- Pure virtual functions, abstract class and interface in C++?
- Multiple inheritance (diamond problem) in C++ and virtual keyword with classes?
- What is casting? static/dynamic/const cast in C++?
- What is final keyword?
I hope this will give you some idea about types of questions you can expect. Please feel free to contact me on LinkedIn if you have any queries/suggestions. Happy Interviewing!