Question: Let's say you have a function int calc (int operand1, int operand2, char op) where op is either'+' or. Instead of overloading this function for
Let's say you have a function int calc (int operand1, int operand2, char op) where op is either'+' or. Instead of overloading this function for each numerical datatype in C++ (e.g. also defining it for float, double, etc., you want to create a generic function that is far more flexible. In the space below, define calc as a template function. If op is neither '+' nor '-', print an error message on cerr and call the system function exit (1); (you may assume that #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
