virtual function A virtual function is a member function of a class that is declared using the keyword virtual and is overridden in a derived class . The function call is resolved at runtime based on the type of object , not the pointer. Need for Virtual Function Function calls are decided at runtime This is called Late Binding (Dyna…
Read moreRun-time polymorphism Run-time polymorphism means the method call is resolved at run time , not at compile time. Use Base class pointer Points to the derived class object Calls the virtual function Key Concepts 1 Inheritance Run-time polymorphism works only with inheritance . class Base { }; class Derived : public Base { …
Read moreCompile-Time Polymorphism (Static Polymorphism) Compile-time polymorphism is the type of polymorphism where the function call is resolved at compile time . The decision is made by the compiler No runtime overhead Faster execution Achieved Using: Function Overloading Operator Overloading Characteristics of Compile-Time Polymorphis…
Read morePolymorphism Polymorphism is a feature of Object-Oriented Programming that allows one interface to be used for different data types or classes. Polymorphism means “many forms” . allows the same function name or operator to behave differently based on: Number of arguments Type of arguments Object calling the function Needs of Pol…
Read moreOverloading Through Friend Function. To access the private/protected data of a class When operator/function logic involves two different classes When operations must be done outside the class To allow symmetrical operations (e.g., sum(obj, 5) or sum(5, obj)) Rules of Friend Function Overloading Rule Description …
Read more
Social Plugin