Question 2: multiply Problem statement In this question first we will practice function overloading and then function templates. Please follow below instructions. We can extend multiplication easily for string types if we interpret the operation as repetition. For example "code" * 3 may be interpreted as "codecodecode". In fact, languages like Python already support this operation. Write a C++ function named multiply that can multiply(repeat) an std::string by a given integer number and return the repeated string. Write another C++ function named multiply that can multiply two given integer (int type) numbers and return the product as an integer. Write another C++ function with the same name that can multiply a floating point number (double type) by a given integer number and return the product as a floating point number. We defined three functions with the same name without a problem. It is either because they have a different number of parameters, or because any of their parameters are of a different type. This allows the compiler to recognize which one to consider; each function is unique though the names are same. What if we can write a single function that can handle all three data types and give the results accordingly? We can do so using C++ function templates. Write a C++ function template named multiply_type that can take any floating point number(double type) or integer(int type) or an std::string as the first parameter and any integer number as the second and returns the respective product of the two. Do the following Write your algorithm as code comments. I recommend to follow UMPIRE technique ( Implement your functions

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
Question 2: multiply Problem statement In this question first we will practice function overloading and then function templates. Please follow below instructions. We can extend multiplication easily for string types if we interpret the operation as repetition. For example "code" * 3 may be interpreted as "codecodecode". In fact, languages like Python already support this operation. Write a C++ function named multiply that can multiply(repeat) an std::string by a given integer number and return the repeated string. Write another C++ function named multiply that can multiply two given integer (int type) numbers and return the product as an integer. Write another C++ function with the same name that can multiply a floating point number (double type) by a given integer number and return the product as a floating point number. We defined three functions with the same name without a problem. It is either because they have a different number of parameters, or because any of their parameters are of a different type. This allows the compiler to recognize which one to consider; each function is unique though the names are same. What if we can write a single function that can handle all three data types and give the results accordingly? We can do so using C++ function templates. Write a C++ function template named multiply_type that can take any floating point number(double type) or integer(int type) or an std::string as the first parameter and any integer number as the second and returns the respective product of the two. Do the following Write your algorithm as code comments. I recommend to follow UMPIRE technique ( Implement your functions
1
2
3
56
Test #
10
10
4
6
2.8
10
"C++"
10
"Rain"
2
%
t
8
ل
6
ال
input
y
=
ال
&
7
Criteria
8
1
9
k
100
24
28.0
"C++C++C++C++C++C++C++C++C++C++"
"RainRain"
.
ه
نام
Output
D
May 17
8:58+ US $
Transcribed Image Text:1 2 3 56 Test # 10 10 4 6 2.8 10 "C++" 10 "Rain" 2 % t 8 ل 6 ال input y = ال & 7 Criteria 8 1 9 k 100 24 28.0 "C++C++C++C++C++C++C++C++C++C++" "RainRain" . ه نام Output D May 17 8:58+ US $
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
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
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