Basic Questions
- What is C++? - C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language. It includes object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
 
- What are the main features of C++? - Object-Oriented Programming
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
- Standard Template Library (STL)
- Exception Handling
 
- What is the difference between C and C++? - C is a procedural programming language, while C++ is both procedural and object-oriented. C++ supports classes and objects, while C does not.
 
- What is a class? - A class is a blueprint for creating objects. It encapsulates data for the object and methods to manipulate that data.
 
- What is an object? - An object is an instance of a class. It contains data and methods defined in the class.
 
Intermediate Questions
- What is inheritance in C++? - Inheritance is a feature of OOP that allows a class to inherit properties and behaviors (methods) from another class.
 
- What is polymorphism in C++? - Polymorphism allows functions to be used interchangeably based on the context. It can be achieved using function overloading, operator overloading, and virtual functions.
 
- Explain the concept of constructors and destructors in C++. - Constructors are special member functions that initialize objects. Destructors are used to clean up when an object is destroyed.
 
- What is the difference between a pointer and a reference in C++? - A pointer can be re-assigned to point to different objects, whereas a reference is a constant alias for an existing object.
 
- What are virtual functions? - Virtual functions allow derived classes to override methods in the base class, enabling runtime polymorphism.
 
Advanced Questions
- What is the Standard Template Library (STL)? - STL is a collection of template classes and functions in C++ for data structures and algorithms, including vectors, lists, queues, and stacks.
 
- What is a template in C++? - A template is a feature that allows functions and classes to operate with generic types. This enables code reusability.
 
- Explain the concept of RAII (Resource Acquisition Is Initialization). - RAII is a programming idiom where resource allocation is tied to object lifetime, ensuring resources are properly released.
 
- What is a smart pointer in C++? - Smart pointers are objects that manage the lifetime of dynamically allocated memory, ensuring automatic memory management.
 
- What is the difference between deep copy and shallow copy? - A shallow copy copies all the member values, whereas a deep copy duplicates everything, including dynamically allocated memory.
 
Memory Management
- What is a memory leak? - A memory leak occurs when dynamically allocated memory is not released back to the system, causing a gradual loss of available memory.
 
- How do you prevent memory leaks in C++? - By using smart pointers or ensuring every newhas a correspondingdelete.
 
- By using smart pointers or ensuring every 
- What is the difference between - mallocand- new?- mallocis a C function for memory allocation, while- newis a C++ operator that also invokes constructors.
 
- What is a dangling pointer? - A dangling pointer is a pointer that references a memory location that has already been deallocated.
 
- Explain the use of the - deleteoperator.- The deleteoperator deallocates memory allocated by thenewoperator and invokes the destructor.
 
- The 
Object-Oriented Programming
- What is encapsulation? - Encapsulation is the bundling of data and methods that operate on that data within a single unit or class.
 
- What is abstraction? - Abstraction hides complex implementation details and exposes only the necessary and relevant features of an object.
 
- What is operator overloading? - Operator overloading allows custom implementation of operators for user-defined types.
 
- What is multiple inheritance? - Multiple inheritance is when a class inherits from more than one base class.
 
- What are pure virtual functions? - Pure virtual functions are declared in a base class and must be implemented by derived classes, making the base class abstract.
 
Miscellaneous
- What is the use of the - friendkeyword?- The friendkeyword allows a function or another class to access private and protected members of the class in which it is declared.
 
- The 
- What is a namespace in C++? - A namespace is a declarative region that provides scope to the identifiers inside it, preventing name conflicts.
 
- Explain the - statickeyword in C++.- staticcan be used for variables and functions. Static variables retain their value between function calls, and static functions are limited to the file scope.
 
- What is the - thispointer?- The thispointer is an implicit pointer passed to non-static member functions of a class, pointing to the object for which the function is called.
 
- The 
- What is a lambda function? - A lambda function is an anonymous function defined using the []syntax, which can capture variables from the surrounding scope.
 
- A lambda function is an anonymous function defined using the 
Design Patterns
- What is a singleton pattern? - The singleton pattern ensures that a class has only one instance and provides a global point of access to it.
 
- What is the factory pattern? - The factory pattern defines an interface for creating objects but lets subclasses alter the type of objects that will be created.
 
- What is the observer pattern? - The observer pattern allows a subject to notify observers about changes without them tightly coupling.
 
- What is the strategy pattern? - The strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable.
 
- What is the command pattern? - The command pattern encapsulates a request as an object, allowing parameterization of clients with different requests.
 
Multithreading
- What is multithreading? - Multithreading allows concurrent execution of two or more threads for maximum utilization of CPU.
 
- What are the different ways to create threads in C++? - Using std::threadfrom the C++11 standard library, using POSIX threads (pthreads), or using platform-specific APIs.
 
- Using 
- What is a race condition? - A race condition occurs when the behavior of software depends on the timing or sequence of uncontrollable events like thread execution.
 
- How do you avoid race conditions? - By using synchronization mechanisms like mutexes, locks, and atomic operations.
 
- What is a deadlock? 
- A deadlock is a situation where two or more threads are blocked forever, waiting for each other to release resources.
Templates and STL
- What are the different types of STL containers? - Sequence containers (vector, list, deque)
- Associative containers (set, map, multiset, multimap)
- Container adapters (stack, queue, priority_queue)
 
- What is the difference between - std::vectorand- std::list?- std::vectoris a dynamic array providing random access, while- std::listis a doubly linked list providing efficient insertions/deletions.
 
- What are iterators? - Iterators are objects that point to an element inside a container and can iterate through the container.
 
- What is the - std::unique_ptr?- std::unique_ptris a smart pointer that owns and manages another object through a pointer and disposes of that object when the- unique_ptrgoes out of scope.
 
- What is the - std::shared_ptr?- std::shared_ptris a smart pointer that maintains a reference count to manage the lifetime of the object it points to.
 
Best Practices
- What is the Rule of Three? - If a class requires a custom destructor, copy constructor, or copy assignment operator, it likely requires all three.
 
- What is the Rule of Five? - Extends the Rule of Three to include move constructor and move assignment operator for better management of resources.
 
- What is a move constructor? - A move constructor transfers resources from a temporary object to a new object, leaving the temporary in a valid but unspecified state.
 
- What is the purpose of the - explicitkeyword?- The explicitkeyword is used to prevent implicit conversions and copy-initialization.
 
- The 
- What is the difference between - throwand- noexcept?- throwspecifies that a function might throw an exception, while- noexceptspecifies that a function does not throw exceptions.
 
Additional Questions
- What is the difference between - constand- constexpr?- constdeclares a variable as constant, while- constexprensures that a variable or function can be evaluated at compile-time.
 
- What are user-defined literals? - User-defined literals allow you to extend the language with custom literals by defining special operator functions.
 
- What is - decltypeused for?- decltypeinspects the declared type of an expression, providing the type without evaluating the expression.
 
- What are - type_traits?- type_traitsis a library in C++ that provides a set of templates to perform compile-time type checking and transformations.
 
- What is a functor in C++? - A functor is an object that can be called as if it were a function, typically by overloading the operator().
 
- A functor is an object that can be called as if it were a function, typically by overloading the 
- What are lambda expressions useful for? - Lambda expressions provide a concise way to define anonymous function objects directly within the scope where they are invoked.
 
- What is the purpose of the - overridekeyword?- The overridekeyword ensures that a member function is overriding a virtual function in a base class, providing better code clarity and compiler checking.
 
- The 
- What is the purpose of the - finalkeyword?- The finalkeyword prevents a class from being inherited or a virtual function from being overridden.
 
- The 
- What is the difference between - std::sortand- std::stable_sort?- std::sortprovides faster sorting but does not guarantee the relative order of equal elements, while- std::stable_sortmaintains the relative order of equal elements.
 
- What is the use of - std::tie?- std::tieis used to unpack tuples into individual variables, often used with- std::tupleto assign values.
 
 

