Ad Code

Responsive Advertisement

function over loading in polymorphism in C++.








programs of function over loading in polymorphism :

#include<iostream>
#include<string.h>
using namespace std;

class A{
 int a,b;
 float c;
 char name[10];
 public:
 void set_a(int a1){
  a=a1;
  cout<<"\n\n single parameter is call";
 } 
 void set_a(int a1,int b1){
  a=a1;
  b=b1;
  cout<<"\n\n dual parameter is call";
 }
 void set_a(int a1,int b1,float c1){
  a=a1;
  b=b1;
  c=c1;
  cout<<"\n\nthree parameter is call"; 
 }
 void set_a(int a1,char *na){
  a=a1;
  strcpy(name,na);
  cout<<"\n\n integer and string parameter is call";
 }
};
int main(){
 A obj;
 char name[]="hello";
 obj.set_a(10);
 obj.set_a(19,20);
 obj.set_a(10,name);
}



out put:
 single parameter is call
dual parameter is call
integer and string parameter is call

If you like code with vibhu  and would like to contribute, you can also write an article using   This link :

https://docs.google.com/forms/d/e/1FAIpQLScAmvlPvNUz35R-G0nc_zpRVP3o8xlhtFgC3aKPyLetX_RyXg/viewform?pli=1


OR  mail your article to bibhutiswain990@gmail.com.  See your article appearing on the code with vibhu main page and help other students. 
❮ Previous                                                      Next ❯

Post a Comment

0 Comments