recursive typedef
Is the following allowed?
typedef Foo<Bar> Bar;
My compiler complains that '开发者_运维技巧class Bar' has a previous declaration as 'class Bar'.
What you are doing is the equivalent of:
struct A {};
struct B {};
typedef A B;
which not suprisingly is not legal.
If Bar is a class as a template parameter for Foo, it can't be the typedefed Foo<Bar>
at the same time.
You would be redeclaring Bar, first as a standalone class and then as a template instantiation, but even typedef Foo<Whatever> Bar;
wouldn't work if you have already declared Bar as a class.
No it is not allowed.
精彩评论