TUTORIAL VIDEO
INTERVIEW QUESTIONS
C++ is a high-level, object-oriented programming language known for its features like classes and objects, inheritance, polymorphism, encapsulation, operator overloading, and templates. It supports both procedural and object-oriented programming paradigms, making it versatile for various applications.
C is a procedural programming language, while C++ supports both procedural and object-oriented programming. C++ introduces features like classes, objects, inheritance, and polymorphism, which are not available in C. Additionally, C++ supports operator overloading, function overloading, and templates.
A constructor is a special member function in C++ that is automatically called when an object of a class is created. It is used to initialize the object and has the same name as the class. Constructors do not have a return type.
Polymorphism is a feature in C++ that allows a single function, operator, or object to behave differently in different contexts. It can be achieved through function overloading, operator overloading, and inheritance. The two types of polymorphism are compile-time (static) and runtime (dynamic).
The "this" pointer in C++ is an implicit pointer available in all non-static member functions of a class. It points to the object for which the member function is called, allowing access to the calling object's members and distinguishing between local variables and class attributes.
A shallow copy copies the values of an object's attributes but not the objects they reference. It duplicates the pointers but not the data they point to. A deep copy, on the other hand, creates an independent copy of the object, including the data referred to by the pointers, ensuring no shared memory.
An inline function in C++ is a function that is expanded in line when invoked, reducing the overhead of function calls. The compiler replaces the function call with the function's code, which can improve performance for small, frequently used functions.
A virtual function in C++ is a member function in a base class that you expect to override in derived classes. It allows runtime polymorphism and ensures the appropriate function is invoked for an object, regardless of the type of reference used to call the function.
Templates in C++ are a feature that allows functions and classes to operate with generic types. This enables code reuse for different data types without the need for multiple code versions. C++ supports both function templates and class templates.
malloc() is a C library function used for dynamic memory allocation and requires manual type casting, while new is a C++ operator that allocates memory and calls the constructor to initialize the object. new automatically returns the correct type and is type-safe.