-
Template question
Hi,
I've just started reading about templates and have an error that I don't quite understand:
Code:
template<class T> struct S {
T val;
S(T n):val(n) {}
};
int main()
{
S<int> a = 2;
cout << a;
cin.get();
return 0;
}
When I run, I get the error message: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'S<T>'
Why won't this print? It looks right to me?
Thanks
-
Oops....what a stupid error! I was trying to print the object rather than the objects member value!
Fixed now. :)