Re: Problem with inheritance and tamplates
From: Rob Williscroft (rtw_at_freenet.co.uk)
Date: 12/06/04
- Next message: Serock: "Re: cast question"
- Previous message: Victor Bazarov: "Re: How can I learn"
- In reply to: David Crocker: "Problem with inheritance and tamplates"
- Next in thread: David Crocker: "Re: Problem with inheritance and tamplates"
- Reply: David Crocker: "Re: Problem with inheritance and tamplates"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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/
- Next message: Serock: "Re: cast question"
- Previous message: Victor Bazarov: "Re: How can I learn"
- In reply to: David Crocker: "Problem with inheritance and tamplates"
- Next in thread: David Crocker: "Re: Problem with inheritance and tamplates"
- Reply: David Crocker: "Re: Problem with inheritance and tamplates"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|