1

Question 2 (8 pts): Will this C++ program compile, and if not why? 001 nclude estring>...

Question

Question 2 (8 pts): Will this C++ program compile, and if not why? 001 nclude estring>...

Question 2 (8 pts): Will this C++ program compile, and if not why? 001 nclude estring> 002 include ccmath> 003 004 uning namespace std 005 006 007 templatesclass T> 008 T operator+ (const Telassa% t1, const Telassct 009 010 templatecclass T> 011 class Tolass( t2); 012 friend T operatort (const TelasseTs t1, const Telasscs t2) 014 Telass (const T& value) :m_value (value)t 015 T NumericValue) constt 016 017 018 private: 019 T value: 020 } ; 021 02 template<class T> 023 T operator+ (const TelassCT% t, const Tclassa% t2){ 024 return t1.NumericValue t2.NumericValue O 025 026 027 int mainO 028 ( powta,b) -?b pow (..),n_value); //power : return 029 Tclass<double> t1 (10) 030 Tclass<double> t2(-10): 031 03 cout << t1 + t2 ; 033 034 return d
Question 2 (8 pts): Will this C++ program compile, and if not why? 001 nclude estring> 002 include ccmath> 003 004 uning namespace std 005 006 007 templatesclass T> 008 T operator+ (const Telassa% t1, const Telassct 009 010 templatecclass T> 011 class Tolass( t2); 012 friend T operatort (const TelasseTs t1, const Telasscs t2) 014 Telass (const T& value) :m_value (value)t 015 T NumericValue) constt 016 017 018 private: 019 T value: 020 } ; 021 02 template<class T> 023 T operator+ (const TelassCT% t, const Tclassa% t2){ 024 return t1.NumericValue t2.NumericValue O 025 026 027 int mainO 028 ( powta,b) -?"b pow (..),n_value); //power : return 029 Tclass<double> t1 (10) 030 Tclass<double> t2(-10): 031 03 cout << t1 + t2 ; 033 034 return d

Answers

Program:

#include <iostream>
#include<string>
#include <cmath>
using namespace std;
template<class T>
T operator+(const Tclass<T>& tl, const Tclass<T>& t2);
template<class T>
class Tclass {
friend T operator+ <> (const Tclass<T>& tl, const Tclass<T>& t2);
public:
Tclass(const T& value) : m_value(value){ }
T NumericValue() const {
return pow(1.0,m_value); //power: pow(a,b) = a^b
}
private:
T m_value;
};
template<class T>
T operetor+(const Tclass<T>& tl, const Tclass<T>& t2){
return tl.NumericValue() + t2.NumericValue();
}
int main()
{
Tclass<double> t1(10);
Tclass<double> t2(-10);
cout << tl + t2;
return 0;
}

Explanation:The Above Program does not compiles.It contains the following Error


Similar Solved Questions

2 answers
Location of image
A compound lens system consists of two converging lenses, one at x=-20 cm with focal length f1=+10.0 cm, and the other at x=+20.0 cm with focal length f2=+8.00. Anobject 1.00 centimeter tall is placed at x=-50.0 cm.What is the location of the final image produced by the compound lens system? Give th...
1 answers
Compute the IRR for Project F. The appropriate cost of capital is 13 percent. (Do not...
Compute the IRR for Project F. The appropriate cost of capital is 13 percent. (Do not round intermediate calculations and round your final answer to 2 decimal places.) Project F Time: 0 1 2 3 4 Cash flow: –$9,900 $3,750 $4,580 $1,920 $2,550...
1 answers
Ау 12- B(1,12) A satellite television reception station is to be located at point P so...
Ау 12- B(1,12) A satellite television reception station is to be located at point P so that the sum of the squares of the distances from P to the three towns A, B, and C is a minimum. Town A is located at (0,0), town B is located at (1,12), and town C is located at (17,0). Find the coord...
1 answers
4. A 0.500 kg piece of copper at an initial temperature of 20.0°C is placed in...
4. A 0.500 kg piece of copper at an initial temperature of 20.0°C is placed in a water bath and the temperature of the metal is raised to 100.0°C. Note: The specific heat capacity of copper is 385J/kg K and the latent heat of fusion is 2.07x1057/kg. a. How much heat was required to raise the...
1 answers
1. Stern Company reports the following selected account balances for 2008: Accounts receivable Administrative expenses Cost...
1. Stern Company reports the following selected account balances for 2008: Accounts receivable Administrative expenses Cost of sales Dividends Income tax expense $ 14,000 Interest income 37,000 Interest expense 415,000 Merchandise inventory 2,200 Sales 64,000 Selling expenses $ 7,000 35,000 50,000 8...
1 answers
Question 7 Not yet anowered Points out of 7.00 g qestion Independent random samples from two...
Question 7 Not yet anowered Points out of 7.00 g qestion Independent random samples from two regions in the same area gave the following chemical measurements (ppm). Assume the population distributions of the chemical are mound-shaped and symmetric two regions for these Region I: 1-12 981 726 686 49...
1 answers
For the following reaction identify the substance oxidized and the substance reduced: 3502 + 2HNO3 +...
For the following reaction identify the substance oxidized and the substance reduced: 3502 + 2HNO3 + 2H20 — 37,804 + 2NO The substance oxidized is: Choose one: O A. NO O B. H2O O C. H2SO4 O D. SO2 O E. HNO3 The substance reduced is: Choose one: O A. SO2 O B. NO O C. H2O O D. HNO3 O E. H2SO4...
1 answers
I don't quite understand this question. 11 Question (2 points) In each chair structure, there is...
I don't quite understand this question. 11 Question (2 points) In each chair structure, there is one bond drawn improperly. ldentify the substituent on the improper bond. 1st attempt Part 1 (1 point) Part 2 (1point)...
1 answers
BOX 34.5 Characteristics of Boötis Exercise 34.5.1. Verify the values of A, 4(GMIRo)n(GMo)2B, dE/dt, and dT/dt...
BOX 34.5 Characteristics of Boötis Exercise 34.5.1. Verify the values of A, 4(GMIRo)n(GMo)2B, dE/dt, and dT/dt for the system i Boötis (Hint: Calculate the unitless quantities GM and ? = m1 m2 / (mit m2) 2 first. Note that GM for the sun is 1477 m.)...
1 answers
4 The Stockholders' Equity section of the balance sheets for Klee Corporation on December 31, 2018,...
4 The Stockholders' Equity section of the balance sheets for Klee Corporation on December 31, 2018, and December 31, 2019, along with other selected account balances on the two dates is provided below. Certain information is missing from the statements.) In 2019, the following transactions affec...
1 answers
Solve the differential equation. du dt 1 + 44 ut? + 14t2 with
Solve the differential equation. du dt 1 + 44 ut? + 14t2 with...
1 answers
Er 20 Shelly Cashman Excel 2019 IM Saved Help S You received no credit for this...
er 20 Shelly Cashman Excel 2019 IM Saved Help S You received no credit for this question in the previous attempt. View The Foundational 15 (LO2-1, LO2-2, LO2-3, LO2-4) [The following information applies to the questions displayed below.) Sweeten Company had no jobs in progress at the beginning of Ma...
2 answers
C++ with Pseudocode in the beginning This assignment will require you to write a program that...
C++ with Pseudocode in the beginning This assignment will require you to write a program that will create an array of 10 string objects. The array will be initialized with the strings which contain the person’s name and phone number in one string. The following is an example of test data: &ldq...
1 answers
Light of wavelength 454 nm is incident on a slit of width 0.22 mm, and a...
Light of wavelength 454 nm is incident on a slit of width 0.22 mm, and a diffraction pattem is produced on a screen that is 2.00 m from the slit. What is the width of the central bright fringe? (1 nm - 10-ºm) 1.7E-2 m 8.3E-3 m 4.1E-3 m 2.5E-2 m 1.0E-3 m...

-- 0.008349--