© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu
Quick Links
Easy Studies

Home Lab Exercise Object Oriented Programming Lab Exercise Programs CPP Program To Implement Function Overloading▼


CPP Program To Implement Function Overloading

Alogarithm steps:

  1. Start the program
  2. Create the function with same name
  3. The function will be differed in return type and number of arguments
  4. Implement the function, which has the same name
  5. Compile and execute the program

CPP Program To Implement Function Overloading

#include #include int abs(int n); double abs(double n); int main() { clrscr(); cout << "Absolute value of -10: " << abs(-10) << endl; cout << "Absolute value of -10.01: " << abs(-10.01) << endl; getch(); return 0; } int abs(int n) { cout << "In integer abs()\n"; return n<0 ? -n : n; } double abs(double n) { cout << "In double abs()\n"; return n<0 ? -n : n; }

SAMPLE INPUT AND OUTPUT:

 in integer abs()

Absolute value of -10:10

In double abs()

Absolute value of -10.01:10.01

 
SLogix Student Projects

⇓Student Projects⇓
⇑Student Projects⇑
bottom