Featured Post

Friday, February 3, 2017

Overloading



/* C++ program to find the power of a given number using operator overloading concept*/

#include<iostream.h>
#include<conio.h>
#include<math.h>
int power(int,int);
float power(float,float);
void main()
{
  int b,p,r;

  float br,pr,rr;
  clrscr();
  cout<<"enter the integer base and integer power";
  cin>>b>>p;
  cout<<"enter the real base and real power";
  cin>>br>>pr;
  r=power(b,p); /* first function will be called*/
  rr=power(br,pr); /* second function will be called*/
  cout<<"the power of"<<b<<"and"<<p<<"is"<<r;
  cout<<"\n"<<"the power of"<<br<<"and"<<pr<<"is"<<rr;
}
int power(int a,int b)
{
   return pow(a,b);
}
float power(float c,float d)
{
  return pow(c,d);
}

Output:
 enter the integer base and integer power
2
2
enter the real base and real power
1.2
3.2
the power of 2 and 2 is 4
the power of 1.2 and 3.2 is 1.792


object,class,inheritance,polymorphism,abstraction, encapsulation, run time polymorphism, static polymorphism, overloading , overriding,. difference between overloading and overriding, templates, drawback of procedural programming


No comments:

Post a Comment