Skip to content

Latest commit

 

History

History
66 lines (54 loc) · 1.04 KB

Readme.md

File metadata and controls

66 lines (54 loc) · 1.04 KB

Mar 3

Polymorphism

1. Overloading

add(int a, int b);
add(float a, float b);

//function call
add(1,2);
add(1.2,2.3);

2. Overriding

The process of redefining the existing data members present in superClass from a base class using inheritance.

superClass{
    methodOne() {
        cout << "Hi";
    }
};

subClass: public superClass{
    methodOne(){
        cout << "Hello";
    }
};
    graphTD;
        Polymorphism-->CompileTime;
        Polymorphism-->Runtime;
        CompileTime-->FunctionOverloading ;
        CompileTime-->OperatorOverloading;
        Runtime-->VirtualFunction;
        Runtime-->FunctionOverriding;
Loading
#include <iostream>
using namespace std;
  
class Parent {
public:
     void hello(){
        cout << "Base Function" << endl;
    }
};
  
class Child : public Parent {
public:
    void hello(){
        cout << "Derived Function" << endl;
    }
};
  
int main() {
    Child he;
    he.hello();

    return 0;
}