D
darkstorm
I have a doubt regarding inheritance involving templates
Consider this:
/////////////////////////////////////
template<typename T>
class A
{
private:
T m_a;
public:
virtual void Draw() = 0;
}
/////////////////////////////////////
template<typename T>
class B : public A<T>
{
public:
B(T w, T h);
private:
///data members....
}
template<typename T>
B<T>::B(T w, T h)
{
m_a = w * h;
}
Error:
error C2248: 'A<T>::m_a' : cannot access private member declared in class 'A<T>'
with
[
T=fp_type
]
and
[
T=fp_type
]
What is the reason behind it? Here I am using public inheritance....
Consider this:
/////////////////////////////////////
template<typename T>
class A
{
private:
T m_a;
public:
virtual void Draw() = 0;
}
/////////////////////////////////////
template<typename T>
class B : public A<T>
{
public:
B(T w, T h);
private:
///data members....
}
template<typename T>
B<T>::B(T w, T h)
{
m_a = w * h;
}
Error:
error C2248: 'A<T>::m_a' : cannot access private member declared in class 'A<T>'
with
[
T=fp_type
]
and
[
T=fp_type
]
What is the reason behind it? Here I am using public inheritance....