Govt. Exams
Entrance Exams
Polymorphism allows objects to take on multiple forms through compile-time (overloading) and runtime (overriding) mechanisms, enabling flexible and extensible code design.
The 'final' keyword (introduced in C++11) prevents a class from being used as a base class for further inheritance.
Accessing private members from outside the class results in a compilation error. The compiler enforces access control at compile time.
The 'this' pointer is an implicit pointer that points to the current object. It's used to access member variables and functions of the current object.
The 'protected' access specifier allows access from within the class and derived classes, but not from outside the class hierarchy.
Virtual functions enable runtime polymorphism by allowing derived classes to override base class methods. The correct method is called based on the object type at runtime.
In C++, the colon (:) operator is used to specify inheritance. Syntax: class Derived : public Base {}
In C++, the default access specifier for class members is 'private'. Only for structs, the default is 'public'.