This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ inheritance question


> Tyler Earman <rem.intellegare@gmail.com> writes:
>
>   
>> Outside of the this-> operators, is there a better way of doing it?
>>     
>
> Not that I know of.
>
>   
>> I've
>> been working with virtual inheritance, by applying virtual interfaces,
>> but this is also generating a large amount of errors (code bellow).
>>     
>
> In your example, the reference to data in C::f appears to be
> non-dependent, but it is actually dependent.  You need to make clear to
> the compiler that it is dependent.  I think using this-> is the best
> approach, and in fact I pretty much always use this-> even when it is
> not required.  In your example, you could also write Base<T>::data.
>
> Ian
>   
Well at least using Base<T>::data seems a bit more intuitive than this->
(as far as readable code goes).  Also it seems to be possible to use the
"using Base<T>::data" declaration, which would be obvious I would guess.

Thanks Ian, I guess that takes care of the issue as far as it can be solved.

-Tyler


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]