problem with g++-4.2 and g++-4.1

A

Alpha

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;
}
 
N

Neelesh Bodas

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top