Examine the tester program to see how the functions are used. overload.cpp 1 #include "overload.h" 2 3 4 5 overload.h 1 #ifndef OVERLOAD H 2 #define OVERLOAD H 3 4 #include 5 6 7 8 9 10 Tester.cpp 4 5 6 1 #include 2 using namespace std; 3 #include "overload.h" 7 8 9 10 // Write your functions here #endif 1121314 15 int main() { } // 2 arguments cout << "product(1.9, 3.4): " << product (1.9, 3.4) << endl; cout << "Expected: 6.46" << endl; // 3 arguments cout << "product (7.5, 9.2, 2.1): " << product (7.5, 9.2, 2.1) << endl; cout << "Expected: 144.9" << endl;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need Help with this c++ problem

Write a pair of functions product which return the product of their arguments. The first takes two, and the second takes three.

### Examine the tester program to see how the functions are used.

---

#### File: `overload.cpp`

```cpp
#include "overload.h"

// Write your functions here
```

---

#### File: `overload.h`

```cpp
#ifndef OVERLOAD_H
#define OVERLOAD_H

#include <string>

#endif
```

---

#### File: `Tester.cpp`

```cpp
#include <iostream>
using namespace std;

#include "overload.h"

int main()
{
    // 2 arguments
    cout << "product(1.9, 3.4): " << product(1.9, 3.4) << endl;
    cout << "Expected: 6.46" << endl;

    // 3 arguments
    cout << "product(7.5, 9.2, 2.1): " << product(7.5, 9.2, 2.1) << endl;
    cout << "Expected: 144.9" << endl;
}
```

---

### Explanation

This code setup is used to demonstrate function overloading in C++. 

- **`overload.cpp` and `overload.h`**: These files would typically contain function definitions and declarations. However, in this example, they are placeholders for you to write your functions.

- **`Tester.cpp`**: The main program file that includes the necessary headers and uses the `product` function, which is expected to be overloaded to handle different numbers of arguments. The program tests `product(1.9, 3.4)` expecting a result of 6.46, and `product(7.5, 9.2, 2.1)` expecting a result of 144.9.

By examining the output statements in `Tester.cpp`, users can see how function overloading allows the same function name to handle different numbers of parameters.
Transcribed Image Text:### Examine the tester program to see how the functions are used. --- #### File: `overload.cpp` ```cpp #include "overload.h" // Write your functions here ``` --- #### File: `overload.h` ```cpp #ifndef OVERLOAD_H #define OVERLOAD_H #include <string> #endif ``` --- #### File: `Tester.cpp` ```cpp #include <iostream> using namespace std; #include "overload.h" int main() { // 2 arguments cout << "product(1.9, 3.4): " << product(1.9, 3.4) << endl; cout << "Expected: 6.46" << endl; // 3 arguments cout << "product(7.5, 9.2, 2.1): " << product(7.5, 9.2, 2.1) << endl; cout << "Expected: 144.9" << endl; } ``` --- ### Explanation This code setup is used to demonstrate function overloading in C++. - **`overload.cpp` and `overload.h`**: These files would typically contain function definitions and declarations. However, in this example, they are placeholders for you to write your functions. - **`Tester.cpp`**: The main program file that includes the necessary headers and uses the `product` function, which is expected to be overloaded to handle different numbers of arguments. The program tests `product(1.9, 3.4)` expecting a result of 6.46, and `product(7.5, 9.2, 2.1)` expecting a result of 144.9. By examining the output statements in `Tester.cpp`, users can see how function overloading allows the same function name to handle different numbers of parameters.
Expert Solution
Step 1

In this question we need to write a C++ program to overload product method such that one product method takes 2 parameters and other product method takes three parameter while each product method returns the product of passed arguments.

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education