On Wed, May 04, 2005 at 05:18:56PM +0200, Wlodzimierz Lipert wrote:
> Hi! A little mistake during copy/paste. :)
>
> template < typename T, int S >
> class A{
>
> public:
> T _V[S ];
> int a;
> }
You're missing a ';' here.
>
> template < typename T >
> class B : public A< T, 2 /* const */ >
> {
> B( T t ) : A<T,2 >::V[0]( t ), A<T, 2>::V[1] ( t ) /* ERROR reported by
This is not legal C++
The initialisation list must name base classes and members.
A<T,2>::V is not a member of B, so cannot be initialised here.
A<T,2>::V[0] is also not a member, and you cannot initialise the
elements of an array like this anyway.
> compiler. Why? */
> , a( 1 ) /* no error */ {};
Are you sure? This is an error. 'a' is not a member of B.
>
> B( T t1, T t2 ){
> A<T,2>::V[0] = t1; // no error.
> }
>
> };
>
> It apears that index operator [] is not treated properly during
> initialization.
--
"All that we are is the result of what we have thought;
it is compounded of our thoughts, made up of our thoughts."
- Dhammapada, Verse I