Re: Problem with inheritance and tamplates

From: Rob Williscroft (rtw_at_freenet.co.uk)
Date: 12/06/04


Date: 6 Dec 2004 14:14:50 GMT

David Crocker wrote in
news:41b43cc2$0$23015$cc9e4d1f@news.dial.pipex.com in comp.lang.c++:

> The following won't compile under Comeau in strict mode, nor under MS
> Whidbey beta in ANSI mode. Can anyone tell me why,

I think this one is now in the FAQ, but anyway the name "bar" in
your code is a template argument dependant name, because its a member
of a base class that is dependent on a template argument.

You need to tell the compiler it is a member name, otherwise it
assumes that bar should be found in an outer scope.

This is part of Two Phase Lookup.

The error occurs when the template body is first parsed, at that time
the compiler doesn't know the template paramiter types, so it doesn't
know the type of the dependant base class or what members that base
class has.

> and which sections
> of the ISO standard apply?

I'd start at 14.6 (Templates / Name Resolution).

> The error messages from Comeau are:
>>>"ComeauTest.c", line 42: error: identifier "bar" is undefined
> return arg->foo() == bar() // line 45
> ^
>
> "ComeauTest.c", line 43: error: identifier "Object" is undefined
> && Object
> ^
>
> <<'bar()' is a public inherited member of the current class and
> 'Object' is a protected inherited member of the current class. If I
> replace them by this->bar() and this->Object, the errors go away.

HTH.

Rob.

-- 
http://www.victim-prime.dsl.pipex.com/


Relevant Pages

  • Re: static member functions access to class members and methods
    ... >> data member of the base class, yet I can assign it directly. ... the base class is a template and if I declare a pure virtual ... keep it protected/private and make the base class a friend, ...
    (comp.lang.cpp)
  • Re: Utility classes?
    ... > reasonable to derive them from a base class and move those operations to the ... creating a utility class seemed reasonable. ... limitations of the language to provide necessary functionality. ... find you need to template those functions to handle different types ...
    (comp.lang.cpp)
  • Re: Empty base class (like Javas "interface")?
    ... > I tried defining it empty in the base class and with a non-empty ... except for the type of value they wrap, define a class template for such ... of utility classes like Dereferencer and Deleter below, ... struct Value: public Value_base ...
    (comp.lang.cpp)
  • Re: Create Group Member
    ... Your question sounds there are other templates other than the .eml template. ... Now you will have an envelope icon on your Desktop that when you click on it, you will have a New Message window with your saved opening & member list ready to go. ... I would suggest putting your email address in the To line to keep the Undisclosed Recipients from showing instead which may be filtered upon. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • member overridding
    ... I have a base class with a static member function. ... I tried overridding my static member in a simple test class derived ...
    (alt.comp.lang.learn.c-cpp)