template class input operator overloading

Basically I have a template class that I want to be able to store data using a function I named void Push(). I want to overload the input operator >> so that I can ask the user to enter in values and it will store them.
1
2
3
4
5
  istream& operator>> (istream &in, STACK <T, n> &s)
	{
		in >> s.Push(x);
		return in;
	}

This doesn't work though. I am not sure why. Any help will be appreciated. Thanks.
what is x ?

1
2
3
4
5
6
7
8
template <class T, /* */ n>
istream& operator >> ( istream& in, STACK <T, n>& s )
{
    T x
    in >> x
    s.Push( x );
    return in;
}
Last edited on
x is what the user will input, i will try this
i try this, but when I put cin >> s (from MyClass <int, 4> s) it still says no operator matches those operands for the class
can you show the relevant code ?
Topic archived. No new replies allowed.