Reputation: 581
class XY{};
template<typename typeA>
class A
{
(...)
};
template<typename typeB>
class B
{
(...)
};
(...)
B<class <class XY>A> * attribute; // <- How can I do that without Syntaxerror
When trying this gcc gives me the following error:
xy.h:19: error: template argument 1 is invalid
How can I avoid that?
Upvotes: 0
Views: 63
Reputation: 303947
The class
keyword is only for defining a template class, not for declaring an object. For that, you just need:
B<A<XY> >* attribute;
Or to spread it out for clarity:
typedef A<XY> MyA;
typedef B<MyA> MyB;
MyB* attribute;
Upvotes: 3
Reputation: 63154
Your question is quite unclear, but I think you're after template template parameters. This way :
template <template <class> class U>
class Foo {};
Now Foo
is a class template accepting another class template as its parameter, like so :
template <class V>
class Bar {};
Foo<Bar> theFoo;
Upvotes: 1