Template Class

create the template class

demo

it has one private data member 'data'

it is a Template type

there are public functions

getData // returns Template Type, no parameters
setData // void return type, one parameter Template Type

friend std::ostream& operator << (std::ostream& os,  demo& s)
// push the text representation of the content to the stream
// this should work just like the ToString functions we have been doing all quarter
// except you will use the stream passed in "os" instead of creating a stringstream
// return os


NOTE it is WAY EASIER to put your function bodies inside the class... 



there is a function in the cmpslib GetClassName that should allow you to determine the datatype at runtime

you will then test your class with "main.cpp" by creating instances of the lab16 class for type int, double and string

your output should match the runable example and the output below

name your file "template_class.h"



./runme Testing with type int a.setData(99) a.getData() returns: 99 cout << a sizeof (data) = 4 data is of type int data contains: 99 Testing with type double b.setData(99.99) b.getData() returns: 99.99 cout << b sizeof (data) = 8 data is of type double data contains: 99.99 Testing with type string c.setData("monkey") c.getData() returns: monkey cout << c sizeof (data) = 8 data is of type std::string data contains: monkey