|
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
Hi,
Can anyone tell the reason why the following code can be compiled using g++-4.1 while g++-4.2 throws a compilation error? template<class A, class B = int> class foo{ public: A i; B j; }; template<class A = int, template<class>class B = foo> class bar : public B<A>{ public: A k; }; int main(){ bar<> test; test.k = test.j = test.i = 0; return 0; } |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
On Oct 15, 11:03 am, Alpha <xinhaoy...@gmail.com> wrote:
> Hi, > > Can anyone tell the reason why the following code can be compiled > using g++-4.1 while g++-4.2 throws a compilation error? > > template<class A, class B = int> > class foo{ > public: > A i; > B j; > > }; > > template<class A = int, template<class>class B = foo> template <class A=int, template <class, class=int>class B = foo> Thats the right way. > class bar : public B<A>{ > public: > A k; > > }; > > int main(){ > bar<> test; > > test.k = test.j = test.i = 0; > > return 0; > > } -N |
|
![]() |
| Outils de la discussion | |
|
|