Is it possible to build a vector of a template class?

I've defined a template class as follow:
template <class T>
class A
{
public:
A<T>(){};

private:
T t;
string s;
};

Then another template class using template class A:
template <class T>
class B
{
public:
B<T>(){};

private:
A<T> t;
vector<A<T>> vec; //error!
};

I've got an error by trying to declare the vector with class A. It seems not the right way to achieve my attempt. What have I done wrong?
The compiler gets confused if the closing >s are right next to each other, and thinks you mean operator>>

1
2
3
4
5
6
7
8
9
10
template <class T>
class B
{
public:
    B(){}; // now need for <T> here

private:
    A<T> t;
    vector<A<T> > vec; // now with a space between the >s
};

Last edited on
Thank you very much! It was the missing space that the compiler complains about.
Topic archived. No new replies allowed.