Question: Overloading I loverloadl.cpp overloaded function 2 Sinclude kiostream> using namespace std 4 prototypes declare two functions with In C++ two different functions S //same names
Overloading I loverloadl.cpp overloaded function 2 Sinclude kiostream> using namespace std 4 prototypes declare two functions with In C++ two different functions S //same names s dirferent perane ter types int operate (int a, int b); can have the same name if 7 float operate (float a float b): 8 int main their parameter types or 10 //declare initialize variables number are different. 11 int x 5, 2 float n 5.0, m 2.0: That means that you can give 13 //use float operate to print 14 cout operate (x,y) l cout "In the same name to more than 15 16 //use int operate to print one function if they have cout operate 18 cout "In either a different number of return 20 21 this function has integer paraneters parameters or different types 22 and returns an integer 23 int operate (int a, int b) in their parameters. 25 return (a b) This is called Overloading 27 //this function has float parameters 28 //and returns a floting point number 29 float operate (float a float b) 30 31 return (a/b) 32 L Programming Logic and Design, Seventh Edition 19
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
