CJCoding With Joseph
15free / daySign inCreate account

Holder Class Template with a Constructor

Complete the class template Holder<T>, which stores one private value of type T:

- Holder(T startValue): stores startValue - T getValue() const: returns the stored value - void setValue(T newValue): replaces the stored value

Each different T makes a separate class: Holder<int>, Holder<double> and Holder<std::string> are three unrelated types that happen to come from one template. The tests create one of each, print the three values (one per line), change the int and the string with setValue, and print those two again.

Do NOT write a main function.

Expected Output:

5
2.5
box
9
crate

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Templates
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.