Thanks Carl.
MyClass<T1, T2>::m_variable is the type name for return. The following is
the code and error messages.
template<class TYPE, class ARG_TYPE>
class suDynList : public CObject
{
protected:
struct suNode
{
suNode* iNext;
suNode* iPrev;
TYPE data;
};
suNode* NewNode(suNode* prev, suNode* next, ARG_TYPE& newElement);
...
template<class TYPE, class ARG_TYPE>
suDynList<TYPE, ARG_TYPE>::suNode* //line 342
suDynList<TYPE, ARG_TYPE>::NewNode(suDynList::suNode* prev,
suDynList::suNode* next,
ARG_TYPE& newElement) //line 343
{
...
c:\...\sudynlist.h(342) : warning C4346: 'suDynList<TYPE,ARG_TYPE>::suNode'
: dependent name is not a type prefix with 'typename' to indicate a type
c:\...\sudynlist.h(342) : error C2143: syntax error : missing ';' before '*'
c:\...\sudynlist.h(342) : error C2501: 'suDynList<TYPE,ARG_TYPE>::suNode' :
missing storage-class or type specifiers
c:\...\sudynlist.h(343) : error C2065: 'TYPE' : undeclared identifier
c:\...\sudynlist.h(343) : error C2065: 'ARG_TYPE' : undeclared identifier
c:\...\sudynlist.h(343) : error C2955: 'suDynList' : use of class template
requires template argument list
c:\...\sudynlist.h(120) : see declaration of 'suDynList'
c:\...\sudynlist.h(345) : error C2061: syntax error : identifier 'ARG_TYPE'
> > Hi there,
> >
[quoted text clipped - 42 lines]
>
> -cd
rich - 26 Jul 2005 00:57 GMT
Thanks again Carl. I tried adding keyword typename in front of some of my
type names and it compiles now. Thanks a lot.
rich
> Thanks Carl.
>
[quoted text clipped - 80 lines]
> >
> > -cd
Ronald Laeremans [MSFT] - 26 Jul 2005 17:55 GMT
> Thanks again Carl. I tried adding keyword typename in front of some of my
> type names and it compiles now. Thanks a lot.
[quoted text clipped - 85 lines]
>>>
>>>-cd
OK, I do have to ask: Can you suggest how we could make the compiler
error message more clear? We worked very hard here to have the compiler
give a really accurate diagnostic, but in practice it still fails to
help many developers. Any suggestions on how to improve it are very welcome.
Thanks!
Ronald Laeremans
Visual C++ team
Hendrik Schober - 27 Jul 2005 10:01 GMT
> [...]
> >>c:\...\sudynlist.h(342) : warning C4346: 'suDynList<TYPE,ARG_TYPE>::suNode'
[quoted text clipped - 3 lines]
> OK, I do have to ask: Can you suggest how we could make the compiler
> error message more clear? [...]
I doubt that you could get much better than saying
"prefix with 'typename' to indicate a type". IMHO
the reason this still gets asked here so often is
that many VC-only developers (do as the VC team did
for many years and) don't care much for the C++ std.
They simply never heard of 'typename', they never
bothered to really learn templates, and never read
a general C++ book. It's only 2 years that you have
a more or less decent compiler regarding templates
(and thus show a different attitude towards std C++)
-- it will take a while for your customers to catch
up. (I don't see it as an incident that many of
those who answer such questions here seem to have
regular exposure to other compilers.)
I expect an even bigger amount of FAQs swamping this
newsgroup should you ever get around to implement
std conforming lookup rules. Porting template code
checked using VC7.1 to other compilers (many of
which do implement proper lookup) is a PITA due to
this.
> Ronald Laeremans
Schobi

Signature
SpamTrap@gmx.de is never read
I'm Schobi at suespammers dot org
"Coming back to where you started is not the same as never leaving"
Terry Pratchett