Polymorphism with an example?

Answer Posted / anil

polymorphism means implementing different functionality's
with the same name and different type of arguments and
different number of parameters.We can achieve polymorphism
using function overloading and function overriding.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the benefits of polymorphism?

858


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

1850


What is the difference between encapsulation and polymorphism?

826


What is the highest level of cohesion?

766


What are properties in oop?

807


What are constructors in oop?

796


What is protected in oop?

809


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1634


What are the benefits of oop?

861


What is oops concept with example?

766


What is inheritance write a program to show use of inheritance?

868


#include #include #include #include void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

3514


Why do we use oops?

755


write a program to find 2 power of a 5digit number with out using big int and exponent ?

2130


What is multilevel inheritance?

950