i've a base class as follows:
//base class- arrayListType.h
class arrayListType
{
public:
//some function members;
protected:
elemType *list;
int length;
int maxSize;
};
and then a derived class:
//derived class- polynomialType.h
#include "arrayListType.h"
class polynomialType: public arrayListType<double>
{
friend ostream& operator<<(ostream& ,const polynomialType&);
friend istream& operator>>(istream& ,polynomialType&);
public:
polynomialType operator+(const polynomialType&);
polynomialType operator-(const polynomialType&);
//polynomialType operator*(const polynomialType&);
double operator() (double x);
polynomialType(int size = 100);
int min(int x,int y) const;
int max(int x,int y) const;
};
But after compiling the code, i got error as;
error C2248: 'arrayListType<elemType>::length' : cannot access protected member declared in class 'arrayListType<elemType>'
i've searched for solutions, but can't find ,please help. definition of operator>> is given for refference;
istream& operator>>(istream is,polynomialType& p)
{
cout << "the degree of this polynomial is" << p.length-1 << endl;
for (int i = 0; i < p.length; i++)
{
cout << "enter coefficient of x^" << i <<": ";
is >> p.list[i];
}
return is;
}
the error shows only for friend functions only, why is it so??