I tried searching the forums but I've come up dry. Can anyone help me with this simple coding excercise. I wanted to template my datatype in my class, but it's coming up with errors.
//template <typename T> //----> i want to use this
class typeClass
{
private:
int myArg; //---->I was trying to use 'T myArg'
public:
};
template <typename T>
void something(T myArg)
{
T thisArg = myArg;
std::cout << thisArg << endl;
}
int main()
{
int i = 22;
float f = 22.3;
char * ch = "hello";
something(i);
something(f);
something(ch[1]);
string s = "world";
something(s);
typeClass myClass;
return 0;
}