Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Inheritance from template problem

Thread Tools

Re: Inheritance from template problem

Balog Pal
Posts: n/a
"DSF" <(E-Mail Removed)>
> Seriously, when I compile the following code, I get the error: "B::i
> is not accessible" on the line "f = Tptr->i".

Yep. Just followinfg the rules.

i is protected member of class B. Why do you think it could be seen from
class D that is not derived from B?

> It compiles fine if "i" is made public.


> I assume it has something to do with the declaration
> of class "D".
> I tried class "D : public A<B>, public B" with the same results.

If you add that you can write
f = i;

However Tptr->i is still not accessible as it is not part of the base class
you inherited but an unrelated instance.

If you really like you can hack around using a pointer-to-member, but I'd
suggest you to forget 'protected' entirely and make a clean public

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
r H2 deduce deduce template argument of a template class inheritingfrom a non template base? nguillot C++ 5 03-08-2009 05:56 PM
How to use the template member function of a template in the memberfunction of another template class? Peng Yu C++ 3 10-26-2008 03:51 PM
template template arguments: expected a class template, got `Component<T1, T2, T3> C++ 1 06-08-2007 07:10 AM
Re: A Newbie Question about template template template tom_usenet C++ 0 07-24-2003 12:06 PM
Re: A Newbie Question about template template template Chris Theis C++ 2 07-24-2003 09:42 AM