Question

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
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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

Add a comment
Know the answer?
Add Answer to:
Question 2 (8 pts): Will this C++ program compile, and if not why? 001 nclude estring>...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 3.) Having a reliable forecast of national economic growth can be important in making investment decisions....

    3.) Having a reliable forecast of national economic growth can be important in making investment decisions. The columns Month, Actualgrowth, Forecast1, Forecast2 and Forecast3 in the associated SPSS file contain actual economic figures over a 24-month period as well as the forecasted growth figures using three separate forecasting techniques. Which of the three forecasting techniques seems to be the best? Month | Actual Growth | Forecast 1 | Forecast 2 | Forecast 3 1   .023   .008   .018   .017 2   .011  ...

  • CAN BE DONE IN ANY LANGUAGE UID Values will be from 000 to 100: 001 002...

    CAN BE DONE IN ANY LANGUAGE UID Values will be from 000 to 100: 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066...

  • + Difference Between Binomial and X ignments/833005 LIBtiariwdVasna 20 30 50 60 01 05 40 10...

    + Difference Between Binomial and X ignments/833005 LIBtiariwdVasna 20 30 50 60 01 05 40 10 70 80 30 640 490 360 250 160 380 902 090 040 2 810 010 002 0+ C 30 420 480 500 320 020 098 180 A80 180 020 250 002 040 090 360 640 0+ 010 160 00 se0 2 857 343 216 064 027 008 01 970 512 125 0 243 375 096 135 432 384 441 280 007 189 375 007...

  • Extended Learning Exercise. You have been asked to prepare a quick estimate of the construction cost...

    Extended Learning Exercise. You have been asked to prepare a quick estimate of the construction cost for a coal-fired electricity generating plant and facilities. A work breakdown structure (levels one through three) is shown in the table below EE! Click the icon to view the work breakdown structure Click the icon to view the available information What is your estimated 2019 cost for building the coal-fired generating facility? Summarize your calculations in a cost estimating worksheet, and state the assumptions...

  • On the psychrometric chart provided mark clearly the point for air with a dry bulb temperature...

    On the psychrometric chart provided mark clearly the point for air with a dry bulb temperature of 30oC and a Percentage Saturation of 80%. At this air condition, by referring to the same chart, what are the values of wet bulb temperature, specific volume, moisture content in kg/kg (dry air) and enthalpy. If the air is air-conditioned to 15oC dry bulb and a Percentage Saturation of 60, what is the associated enthalpy drop. NAT BEBE Reduced scale CIBSE psychrometric chart...

  • I need help with this program c++ - console aplication The attached file is a list...

    I need help with this program c++ - console aplication The attached file is a list of all the Long Island Railroad stations. Each station is described on one line with six space-delimited fields. Each station has a unique 3-character numeric ID, a station name, a branch to which it belongs, a list of the IDs of other stations to which it connects, the station's longitude and latitude, and a final field describing the source of the information. Write a...

  •    number 7 is what I'm asking about here's Macon Ga table data

       number 7 is what I'm asking about here's Macon Ga table data dit View History Bookmarks People Window Help 19% E) Sat Mar 23 4:5 Invalid xESCPXWater Filel/Users/Steven/Downloads/ENVE%204435%20Fall%202016%20Exam%20%232%20Practice%20Problems%20[Post].pdf a You have been asked to design a culvert to handle the discharge for a 50-year storm on a 19-acre catchment in Macon, Georgia Neighborhoods constitute 60% of the land use with the remainder being open space lawns, average condition, with clay soils and average slope. The catchment is characterized hydraulically by...

  • Write MySQL query statements for the questions below including the output that proves the accuracy of...

    Write MySQL query statements for the questions below including the output that proves the accuracy of your solution. Your answers should be stored in a text file that captures your interaction with MySQL. 1. Find the movieID, title, year and DVDPrice of all movies where the DVD-Price is equal to the discountPrice. 2. Find the actorID, lastName, firstName, middleName, and suffix of all actors whose middleName is not NULL. 3. Suppose you remember a movie quote as “Play it again,...

  • Problem 22-06 Management of TSC, Inc. is evaluating a new $97,000 investment with the following estimated...

    Problem 22-06 Management of TSC, Inc. is evaluating a new $97,000 investment with the following estimated cash flows: Year Cash Flow $ 7,000 31,000 41,000 55,000 The firm's cost of capital is 12 percent and the project will require that the firm spend $12,000 to terminate the project. Use Appendix B to answer the question. Use a minus sign to enter a negative value, if any. Round your answer to the nearest dollar. The NPV of the investment is $...

  • 2 homework a Derick Iverson is a divisional manager for Holston Company. His annual pay raises...

    2 homework a Derick Iverson is a divisional manager for Holston Company. His annual pay raises are largely determined by his division's return on Investment (ROI), which has been above 20% each of the last three years. Derrick is considering a capital budgeting project that would require a $3,000,000 investment in equipment with a useful life of five years and no salvage value. Holston Company's discount rate is 15%. The project would provide net operating income each year for five...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT