Govt. Exams
Entrance Exams
In C++, a pure virtual function is declared by adding '= 0' after the function signature. C++ does not have 'abstract' or 'pure' keywords like Java.
Hierarchical inheritance occurs when one base class is inherited by multiple derived classes. Multiple inheritance is when one class inherits from multiple base classes.
Private members are accessible only within the class itself and to friend functions/classes. They are not accessible to derived classes or external code.
The 'protected' access specifier allows derived classes to access the member while keeping it hidden from external classes. This provides the needed balance for inheritance hierarchies.
The 'this' pointer is an implicit pointer that points to the current object instance. It is used to access members of the current object and to return a reference to the current object.
Function overloading allows multiple functions to have the same name as long as they differ in number, type, or order of parameters. Return type alone is not sufficient.
Polymorphism enables a function to work with objects of different types through a common base class interface, providing flexibility and extensibility.
'Poly' means many and 'morph' means form. Polymorphism allows objects to take many forms through method overloading and overriding.
The base class constructor is always called before the derived class constructor to ensure proper initialization of inherited members.
Private members are accessible only within the same class. Public members are accessible from anywhere, and protected members are accessible in derived classes.