Functional Programming Tutorial
Functional Programming Resources
Selected Reading
- File I/O Operations
- Lazy Evaluation
- Lambda Calculus
- Records
- Tuple
- Lists
- Strings
- Polymorphism
- Data Types
- Higher Order Functions
- Recursion
- Function Overriding
- Function Overloading
- Call By Reference
- Call By Value
- Function Types
- Functions Overview
- Introduction
- Home
Functional Programming Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Function Overriding
Function Overriding
When the base class and derived class have member functions with exactly the same name, same return-type, and same arguments pst, then it is said to be function overriding.
Function Overriding using C++
The following example shows how function overriding is done in C++, which is an objectoriented programming language −
#include <iostream> using namespace std; class A { pubpc: void display() { cout<<"Base class"; } }; class B:pubpc A { pubpc: void display() { cout<<"Derived Class"; } }; int main() { B obj; obj.display(); return 0; }
It will produce the following output
Derived Class
Function Overriding using Python
The following example shows how to perform function overriding in Python, which is a functional programming language −
class A(object): def disp(self): print "Base Class" class B(A): def disp(self): print "Derived Class" x = A() y = B() x.disp() y.disp()
It will produce the following output −
Base Class Derived ClassAdvertisements