Re: Inheritance from template problem
DSF <notavalid@address.here> wrote in
news:va8ns7tbn6rce8sf7c93bh6u7911icmsg6@4ax.com:
Hello,
My inheritance problem is my uncle left me $10 million, but to get it
I have to spend the night in an isolated haunted house. My uncle
didn't like me. I think it's a plot to kill me! :o)
Seriously, when I compile the following code, I get the error: "B::i
is not accessible" on the line "f = Tptr->i". 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.
Have I missed something simple?
I think yes. B::i is declared protected, meaning that only B or a class
derived from B can access it. There is no class derived from B. So...?
hth
Paavo
template <class T> class A
{
protected:
T *Tptr;
};
class B
{
public:
protected:
int i;
};
class D : public A<B>
{
public:
void foo(void);
};
void D::foo(void)
{
int f;
f = Tptr->i;
}
DSF