Question: Write a C++ program that will read in values and return the sum of different data types. Write a function T accum(vector v) that forms

Write a C++ program that will read in values and return the sum of different data types. Write a function T accum(vector v) that forms and returns the "sum" of all items in the vector v passed to it. For example, if T is a numeric type such as int or double, the numeric sum will be returned. If T represents the STL string type, the result of concatenation is returned. Use input file tempData.txt as input. The first five lines will hold integer values. Sum these values. The next six lines hold string values. "Sum" (concatenate) these string values together. For each type, display the values and their respective sums. NOTE: for any type T, the expression T( ) yields the value or object created by the default constructor. For example, T() yields the empty string object if T is the string class. If T represents a numeric type such as int, then T() yields 0. You may find this helpful when initializing your accumulator. Be sure to use good programming methodology and keep your project modular.

the tempData.txt has the following

101 599 245 853 99 Exceptions are used to signal errors

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!