Overloading Functions in C++
P | N


Multiple signatures can be distinguished if input is distinguishable.

#include <iostream.h>

int add_values(int a, int b)

{

return (a + b);

}

int add_values(int a, int b, int c)

{

return(a + b + c);

}

void main(void)

{cout << "200 + 801=" << add_values (200, 801) << endl;

cout << "100+201+700=" << add_values(100,201,700) << endl;

}


Previous | Next


Last modified at 8/5/97; 12:31:27 PM
Other Links of Interest
College of Computing | EduTech Institute | GVU Center
Mark Guzdial | Papers | CS 2390 Spring '97 Home Page | STABLE | MMC-CaMILE

Slide Master