K
karolszk
Hi!
The following program gcc returns error:
class Z
{
int a;
int b;
};
template <class Element>
class A
{
public:
A()
{
}
protected:
//Z *a;
Z& a;
};
template <class Element>
class B : public A<Element>
{
public:
B()
{
};
~B()
{
delete &A<Element>::a; // here is problematic line
}
};
int main()
{
B<int> b;
return 0;
}
protected.cpp: In destructor 'B<Element>::~B() [with Element = int]':
protected.cpp:34: instantiated from here
protected.cpp:16: error: 'Z& A<int>::a' is protected
protected.cpp:28: error: within this context
protected.cpp:28: confused by earlier errors, bailing out
which I can't understand why?? When I change A::a member from reference
to pointer the error not appears.
Why I can't delete protected member A::a from the subclass B....
Please help me,
Karol
The following program gcc returns error:
class Z
{
int a;
int b;
};
template <class Element>
class A
{
public:
A()
{
}
protected:
//Z *a;
Z& a;
};
template <class Element>
class B : public A<Element>
{
public:
B()
{
};
~B()
{
delete &A<Element>::a; // here is problematic line
}
};
int main()
{
B<int> b;
return 0;
}
protected.cpp: In destructor 'B<Element>::~B() [with Element = int]':
protected.cpp:34: instantiated from here
protected.cpp:16: error: 'Z& A<int>::a' is protected
protected.cpp:28: error: within this context
protected.cpp:28: confused by earlier errors, bailing out
which I can't understand why?? When I change A::a member from reference
to pointer the error not appears.
Why I can't delete protected member A::a from the subclass B....
Please help me,
Karol