overload.cpp 1 #include "overload.h" 2 3 4 5 6 7 } 8 overload.h 123456 #ifndef OVERLOAD H 2 #define OVERLOAD H 3 // Write your functions here float product (const double& a, const double& b) { return a * b; 4 #include 5 float product(const double& a, const double& b, const double& c) 7 { 8 return a*b* c; 9} 10 11 12 13 #endif Tester.cpp 1 #include 2 using namespace std; 3 4 #include "overload.h" 5 6 7 8 9 10 11 12 13 14 15 int main() { } // 2 arguments cout << "product(6.2, 6.4): " << product (6.2, 6.4) << endl; cout << "Expected: 39.68000000000001" << endl; // 3 arguments cout << "product (1.1, 7.0, 4.1): " << product (1.1, 7.0, 4.1) << endl; cout << "Expected: 31.57" << endl;
overload.cpp 1 #include "overload.h" 2 3 4 5 6 7 } 8 overload.h 123456 #ifndef OVERLOAD H 2 #define OVERLOAD H 3 // Write your functions here float product (const double& a, const double& b) { return a * b; 4 #include 5 float product(const double& a, const double& b, const double& c) 7 { 8 return a*b* c; 9} 10 11 12 13 #endif Tester.cpp 1 #include 2 using namespace std; 3 4 #include "overload.h" 5 6 7 8 9 10 11 12 13 14 15 int main() { } // 2 arguments cout << "product(6.2, 6.4): " << product (6.2, 6.4) << endl; cout << "Expected: 39.68000000000001" << endl; // 3 arguments cout << "product (1.1, 7.0, 4.1): " << product (1.1, 7.0, 4.1) << endl; cout << "Expected: 31.57" << 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
Related questions
Question
Having trouble writing these functions, what am I doing wrong?
Expert Solution
Program approach
Prototype of both the overloaded functions must be declared in "overload.h" and the functions must be defined in "overload.cpp". Import "overload.cpp" in "tester.cpp" and invoke the functions to get the expected output.
Step 1: Declare the function prototypes for product function with two and three arguments in the overload.h header file.
Step 2: Define the overloaded member functions in overload.cpp file.
Step 3: Define the main() function in Tester.cpp. Invoke the product() member function by passing two and three arguments and display the value returned.
Step by step
Solved in 4 steps with 4 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education