Q51. What is recursion in C++?

Recursion is a technique where a function calls itself to solve a smaller part of a problem. It must have a base condition to stop infinite calls. It is commonly used in problems like factorial, Fibonacci, tree traversal, etc.

Q52. What is a function template?

A function template allows writing generic functions that work with different data types. The compiler generates the appropriate function based on the data type used during function call.

Q53. What is function overriding?

Function overriding occurs when a derived class provides its own implementation of a function that is already defined in the base class using virtual keyword.

Q54. What is lambda function?

Lambda functions are anonymous functions introduced in C++11. They are mainly used for short operations and with STL algorithms.

Q55. What is call stack?

Call stack is a memory structure that stores function calls in LIFO order. Each function call creates a stack frame containing local variables and parameters.

Q56. What is multiple inheritance?

Multiple inheritance allows a class to inherit properties from more than one base class.

Q57. What is hierarchical inheritance?

Hierarchical inheritance occurs when multiple classes inherit from a single base class.

Q58. What is hybrid inheritance?

Hybrid inheritance is a combination of more than one type of inheritance.

Q59. What is diamond problem?

The diamond problem occurs in multiple inheritance when two derived classes inherit from the same base class and a further class inherits from both of them. It creates ambiguity which is solved using virtual inheritance.

Q60. What is virtual inheritance?

Virtual inheritance ensures that only one copy of the base class is inherited, preventing duplication.

Q61. What is this pointer?

The this pointer refers to the calling object inside a class member function.

Q62. What is static data member?

Static data members belong to the class rather than objects. All objects share the same static variable.

Q63. What is static member function?

Static member functions can access only static data members and are called using class name.

Q64. What is mutable keyword?

Mutable allows a data member to be modified even if it belongs to a const object.

Q65. What is explicit constructor?

Explicit constructor prevents implicit conversions.

Q66. What is bad_alloc exception?

bad_alloc is thrown when memory allocation using new fails.

Q67. What is memory leak?

Memory leak occurs when allocated memory is not released using delete, leading to wasted memory.

Q68. What is RAII?

Resource Acquisition Is Initialization is a technique where resources are allocated in constructor and released in destructor.

Q69. What is smart pointer?

Smart pointers automatically manage memory and prevent memory leaks. Examples: unique_ptr, shared_ptr, weak_ptr.

Q70. Difference between new/delete and malloc/free?

new/delete are C++ operators supporting constructors and destructors. malloc/free are C functions without object construction support.

Data Structures & STL

Q71. What is STL in C++?

Standard Template Library provides containers, algorithms, and iterators.

Q72. Types of STL containers?

  • Sequence containers (vector, list, deque)
  • Associative containers (set, map)
  • Unordered containers
  • Container adapters (stack, queue)

Q73. What is iterator?

Iterator is an object that points to elements inside a container.

Q74. What is difference between vector and list?

Vector stores elements in contiguous memory, list uses nodes connected by pointers.

Q75. What is priority_queue?

Priority queue is a container adapter where highest priority element is removed first.

Q76. What is unordered_map?

unordered_map stores key-value pairs using hash table.

Q77. What is time complexity of vector push_back?

Average O(1), worst O(n) when resizing occurs.

Q78. What is difference between set and unordered_set?

set stores sorted unique elements, unordered_set stores unique elements without order.

Q79. What is emplace_back?

emplace_back constructs object directly inside container without copying.

Q80. What is difference between map and multimap?

map allows unique keys, multimap allows duplicate keys.

Q81. Why use namespaces?

To avoid naming conflicts in large projects.

Q82. What is scope resolution operator?

:: operator is used to define class functions outside class and access namespace members.

Q83. What is anonymous namespace?

Anonymous namespace restricts visibility to current file only.

Q84. What is inline namespace?

Inline namespace allows versioning of libraries.

Q85. What is using declaration?

It introduces specific names from namespace into current scope.

Advanced OOP & Modern C++

Q86. What is move constructor?

Move constructor transfers ownership of resources from temporary object.

Q87. What is rvalue reference?

Rvalue reference (&&) binds to temporary objects.

Q88. What is nullptr?

nullptr is a keyword representing null pointer introduced in C++11.

Q89. What is auto keyword?

auto automatically deduces variable type at compile time.

Q90. What is enum class?

enum class provides strongly typed enumerations.

Q91. What is constexpr?

constexpr specifies that value can be evaluated at compile time.

Q92. What is thread in C++?

Thread allows concurrent execution using <thread> library.

Q93. What is mutex?

Mutex is used to prevent race conditions in multithreading.

Q94. What is file handling in C++?

File handling is done using fstream library to read and write files.

Q95. What is type casting in C++?

C++ provides static_cast, dynamic_cast, const_cast, reinterpret_cast.

Q96. What is shallow copy?

Shallow copy copies object values but not dynamically allocated memory.

Q97. What is deep copy?

Deep copy creates separate memory allocation for dynamic data.

Q98. What is virtual destructor?

Virtual destructor ensures proper cleanup of derived class objects.

Q99. What is aggregation?

Aggregation represents weak relationship between classes.

Q100. What is composition?

Composition represents strong ownership relationship between classes.

📢 Join Our WhatsApp Channel

💼 Get Daily IT Job Updates, Interview Preparation Tips & Instant Alerts directly on WhatsApp.

👉 Join WhatsApp Now

📢 Join Our Telegram Channel

💼 Get Daily IT Job Updates, Interview Tips & Exclusive Alerts directly on Telegram!

👉 Join Telegram

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2022 - 2025 itfreesource.com

Enable Notifications OK No thanks