All question banksProgramming Languages
C++ Questions A comprehensive guide to C++ interview questions covering core syntax, object-oriented programming, and memory management. Essential for developers preparing for technical rounds.
1. What is C++? How is it different from C? Beginner 2. What are the main features of C++? Beginner 3. What is the difference between struct and class in C++? Beginner 4. What are access specifiers in C++? Beginner 5. What is encapsulation? Intermediate 6. What is abstraction? Intermediate 7. What is inheritance? Intermediate 8. What is polymorphism? Intermediate 9. What are the different types of inheritance in C++? Intermediate 10. What is the difference between public, private, and protected inheritance? Advanced 11. What is a constructor? What are its types? Beginner 12. What is a destructor? Beginner 13. What is the difference between constructor and destructor? Beginner 14. Can we have a virtual constructor? Advanced 15. Can we have a virtual destructor? Intermediate 16. What is a copy constructor? Intermediate 17. What is a default constructor? Beginner 18. What is the difference between shallow copy and deep copy? Advanced 19. What is operator overloading? Intermediate 20. What is function overloading? Beginner 21. What is function overriding? Intermediate 22. What is the difference between overloading and overriding? Intermediate 23. What are virtual functions? Intermediate 24. What is a pure virtual function? Intermediate 25. What is an abstract class? Intermediate 26. What is an interface in C++? Intermediate 27. What is the difference between abstract class and interface? Advanced 28. What is early binding and late binding? Intermediate 29. What is dynamic binding? Advanced 30. What is static binding? Intermediate 31. What is the diamond problem in C++? Advanced 32. How do you resolve the diamond problem? Advanced 33. What is virtual inheritance? Advanced 34. What are friend functions? Intermediate 35. What are friend classes? Intermediate 36. What is the 'this' pointer? Beginner 37. Can we delete 'this' pointer? Advanced 38. What is a static member variable? Intermediate 39. What is a static member function? Intermediate 40. Can static functions access non-static members? Intermediate 41. What is the difference between new and malloc? Intermediate 42. What is the difference between delete and free? Intermediate 43. What is a memory leak? Beginner 44. How do you prevent memory leaks? Intermediate 45. What are smart pointers in C++? Intermediate 46. What is unique_ptr? Intermediate 47. What is shared_ptr? Intermediate 48. What is weak_ptr? Advanced 49. What is the difference between stack and heap memory? Intermediate 50. What is dynamic memory allocation? Beginner 51. What is RAII (Resource Acquisition Is Initialization)? Advanced 52. What is the difference between delete and delete[]? Intermediate 53. What happens if you use delete instead of delete[] for arrays? Advanced 54. What is a dangling pointer? Intermediate 55. What is a void pointer? Intermediate 56. What is a null pointer? Beginner 57. What is nullptr in C++11? Intermediate 58. What is the difference between NULL and nullptr? Advanced 59. What are the memory segments in C++? Advanced 60. What is placement new? Advanced 61. What is the difference between pointer and reference? Beginner 62. Can we have a null reference? Intermediate 63. Can we change what a reference refers to after initialization? Intermediate 64. What is a pointer to pointer? Intermediate 65. What is a reference to pointer? Advanced 66. What are function pointers? Intermediate 67. What is the size of a pointer? Beginner 68. What is pointer arithmetic? Intermediate 69. What is a const pointer? Intermediate 70. What is a pointer to const? Intermediate 71. What is const reference? Beginner 72. What is the difference between pass by value, pass by reference, and pass by pointer? Intermediate 73. What is a wild pointer? Beginner 74. What is address of operator (&)? Beginner 75. What is dereference operator (*)? Beginner 76. What are templates in C++? Intermediate 77. What is function template? Intermediate 78. What is class template? Intermediate 79. What is template specialization? Advanced 80. What is the difference between template and macro? Advanced 82. What are the main components of STL? Intermediate 83. What are containers in STL? Beginner 84. What are iterators in STL? Intermediate 85. What are algorithms in STL? Beginner 86. What is the difference between vector and array? Beginner 87. What is the difference between vector and list? Intermediate 88. What is the difference between map and unordered_map? Advanced 89. What is the difference between set and multiset? Intermediate 90. What is the time complexity of vector insertion? Intermediate 91. What is the time complexity of map search? Intermediate 92. What are sequence containers? Beginner 93. What are associative containers? Intermediate 94. What are container adapters? Intermediate 95. What is an iterator invalidation? Advanced 96. What is exception handling in C++? Beginner 97. What are the keywords used for exception handling? Beginner 98. What is the difference between throw and throws? Advanced 99. What is stack unwinding? Advanced 100. What is a namespace? Beginner 101. What is the std namespace? Beginner 102. What is the using directive? Beginner 103. What are inline functions? Intermediate 104. What is the difference between inline and macro? Intermediate 105. What is a lambda expression in C++11? Intermediate 106. What is auto keyword in C++11? Beginner 107. What is decltype? Advanced 108. What is move semantics in C++11? Advanced 109. What is an rvalue reference? Advanced 110. What is perfect forwarding? Advanced 111. What are variadic templates? Advanced 112. What is constexpr? Intermediate 113. What is the explicit keyword? Intermediate 114. What is the mutable keyword? Advanced 115. What is the volatile keyword? Advanced 116. What is the difference between const and constexpr? Intermediate 117. What are static libraries and dynamic libraries? Intermediate 118. What is name mangling? Advanced 119. What is extern "C"? Advanced 120. What is multiple inheritance? Intermediate 121. What is the Rule of Three/Five/Zero? Advanced 122. What is copy elision? Advanced 123. What is Return Value Optimization (RVO)? Advanced 124. What are the differences between C++98, C++11, C++14, C++17, and C++20? Intermediate 125. What is thread safety? Intermediate 126. What are mutex and locks? Intermediate 127. What is the difference between struct and union? Beginner 128. What is the sizeof operator? Beginner 129. What is type casting in C++? What are its types? Intermediate 130. What is the difference between static_cast and dynamic_cast? Advanced