This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: template problem
- From: andy <andy at softbook dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Wed, 09 Oct 2002 11:45:58 -0700
- Subject: Re: template problem
Thanks to all who responded.
typename did indeed fix it.
Regards
Andy
On 10/9/02 10:12 AM, "Moore, Mathew L" wrote:
> The compiler doesn't realize that _DataType is a typename within DataClass
> (it could, after all, be a function or variable), so you have to explicitly
> tell it. This is accomplished using the "typename" keyword:
>
> template <class FilterClass, class DataClass>
> class P2PassScale
> {
> public:
> typedef typename DataClass::_DataType _DataType;
> ...
>
>
>
>> -----Original Message-----
>> From: andy [mailto:andy@softbook.com]
>> Sent: Wednesday, October 09, 2002 12:34
>> To: gcc-help@gcc.gnu.org
>> Subject: template problem
>>
>>
>> I'm having trouble compiling the following in gcc3.2:
>>
>> template <class FilterClass, class DataClass = CDataCOLORREF>
>>
>> class C2PassScale
>> {
>> public:
>> typedef DataClass::_DataType _DataType; //ERROR -see below
>> typedef DataClass::_RowType _RowType;
>> ....
>>
>>
>> //class CDataCOLORREF is declared below in the same file
>> class CDataCOLORREF {
>> public:
>> typedef unsigned long_DataType;
>> ....
>>
>> ERROR above reads:
>> "ISO C++ forbids declaration of _DataType with no type"
>>
>> Now, if I understand the code correctly, the _DataType
>> variable of the
>> C2PassScale class is typedef'ed to be the same as _DataType
>> variable of the
>> the CDataCOLORREF class, i.e, long.
>> It looks like gcc cannot figure out what type the _DataType
>> variable of
>> C2PassScale class needs to be.
>> I wonder if anyone can help finding a workaround or maybe a
>> compile option I
>> need to turn on
>>
>> Thanks in advance
>> Andy
>>
>>