From 7507925b27f4386bde8c5397896553f986bc614f Mon Sep 17 00:00:00 2001 From: ayush kumar <36650811+Ayushchauha111@users.noreply.github.com> Date: Sat, 19 Oct 2019 02:37:33 +0530 Subject: [PATCH] Create compile time polymorphism.c example of compile time polymorphism a important concept of oop --- IntroToOOP/compile time polymorphism.c | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 IntroToOOP/compile time polymorphism.c diff --git a/IntroToOOP/compile time polymorphism.c b/IntroToOOP/compile time polymorphism.c new file mode 100644 index 0000000..e0ddd31 --- /dev/null +++ b/IntroToOOP/compile time polymorphism.c @@ -0,0 +1,31 @@ +/* +Polymorphism is a feature of OOPs that allows the object to behave differently in different conditions. In C++ we have two types of polymorphism: +1) Compile time Polymorphism – This is also known as static (or early) binding. +2) Runtime Polymorphism – This is also known as dynamic (or late) binding. +*/ +#include +using namespace std; +class Add { +public: + int sum(int num1, int num2){ + return num1+num2; + } + int sum(int num1, int num2, int num3){ + return num1+num2+num3; + } +}; +int main() { + Add obj; + //This will call the first function + cout<<"Output: "<