-
What is C++?
- C++ is a general-purpose programming language that is an extension of the C programming language. It supports both procedural and object-oriented programming paradigms.
-
What is the difference between C and C++?
- C++ is an extension of C and includes features like classes and objects, inheritance, polymorphism, and encapsulation, which are not present in C.
-
Explain the concept of Object-Oriented Programming (OOP) and its pillars.
- OOP is a programming paradigm that uses objects and classes. The four pillars of OOP are encapsulation, inheritance, polymorphism, and abstraction.
-
What is a class and an object in C++?
- A class is a blueprint for creating objects, and an object is an instance of a class.
-
What is the difference between public, private, and protected access specifiers?
- Public members are accessible from outside the class, private members are only accessible within the class, and protected members are accessible within the class and its subclasses.
-
Explain the concept of constructor and destructor in C++.
- A constructor is a special member function that is called when an object is created. A destructor is a special member function that is called when an object goes out of scope or is explicitly deleted.
-
What is function overloading and operator overloading?
- Function overloading is the ability to define multiple functions with the same name but different parameter lists. Operator overloading is the ability to redefine the behavior of operators for user-defined data types.
-
What is the difference between reference and pointer?
- A reference is an alias for a variable, and once a reference is initialized, it cannot be changed to refer to another variable. A pointer is a variable that stores the address of another variable, and it can be changed to point to a different variable.
-
What is dynamic memory allocation in C++?
- Dynamic memory allocation in C++ is done using operators
new
anddelete
ormalloc()
andfree()
. It allows the allocation and deallocation of memory during program execution.
- Dynamic memory allocation in C++ is done using operators
-
Explain the concept of virtual functions and pure virtual functions.
- Virtual functions are functions declared in a base class that can be overridden by derived classes. A pure virtual function is a virtual function with no implementation in the base class, making it necessary for derived classes to provide an implementation.
-
What is the use of the
const
keyword in C++?- The
const
keyword is used to declare constants, indicate that a variable cannot be modified, and specify that a member function does not modify the object it is called on.
- The
-
Explain the difference between pass by value and pass by reference.
- Pass by value involves passing the actual value of a variable to a function, while pass by reference involves passing the memory address (reference) of a variable. Changes made to the parameter in pass by reference affect the original variable.
Comments