POLYMORPHISM
POLYMORPHISM
POLYMORPHISM
DEFINITION
• Compile-time Polymorphism
• Runtime Polymorphism
1. COMPILE-TIME
POLYMORPHISM
• Output
• value of x is 7
• value of x is 9.132
• value of x and y is 85, 64
B. OPERATOR OVERLOADING
• #include <iostream>
• using namespace std;
•
• class Base {
• public:
• void print() {
• cout << "Base Function" << endl;
• }
• };
• int main() {
• Derived d1;
• d1.print();
• return 0;
• }
OUTPUT
Derived Function
B. VIRTUAL FUNCTION