Question: Define template struct S { T val: };. Add a constructor. so that you can initialize with a T. Define variables of types S ,
Define template struct S { T val: };. Add a constructor. so that you can initialize with a T. Define variables of types S , S , S , S , and S >: initialize them with values of your choice. Read those values and print them. Add a function template get () that returns a reference lo val. Put the definition of get() outside the class. Make val private. Do 4 again using gel(). Add a set() function template so that you can change val. Replace set() with an S :: operator = (const T&). Provide const and non-const versions of get(). Define a function template read_val(T& v) that reads from cin into v. Use read_val() to read into each of the variables from 3 except the S > variable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
