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: "<