[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: G++ rejects legal code



> Am doing right by posting this here? (A copy has gone to GNATS as well.)

I think so. I fail to see the bug in your report, though. Your code is
illegal (or, rather, ill-formed - some GNU coding style advises us not
to claim that you are breaking the law by writing the code).

> template <class _TW, class _TTWO>
> struct SGBMb : public SGBb <_TW>
> {
>  typedef _TTWO _TWO;
>  _TWO osy;
> 
>  SGBMb <_TW, _TWO> (_TW _sy, _TWO _osy, void* _st)
>   : sy (_sy), osy (_osy), st (_st) {}
> };

The class SGBMb (i.e. all instantiations of the class template) has
only one data member, namely osy. The members sy and st are defined in
the base class, so they must not be mentioned in the member
initializer of the derived class. Instead, you should write

template <class _TW, class _TTWO>
struct SGBMb : public SGBb <_TW>
{
 typedef _TTWO _TWO;
 _TWO osy;

 SGBMb <_TW, _TWO> (_TW _sy, _TWO _osy, void* _st)
  : SGBb<_TW>(_sy, _st), osy (_osy) {}
};

Regards,
Martin



Reply to: