I have an assignment that I am stuck on and I have researched all day and come up empty handed:
I am working with two classes: ClassA
must have a unique overloaded assignment and overloaded insertion. ClassB
must have a unique overloaded assignment, overloaded extraction, and overloaded insertion.
ClassA
has data members: int altitude
, char code
, string area
ClassB
has only an array of classA
: classA* data[30]
All of the overloaded operators must be unique in each class. When I overload insertion or extraction for ClassB
I get an error that the datamember is private which I assume is because the array I am reading into is of data type ClassA
. I am not allowed to replicate friend functions from ClassB
into ClassA
. Is this even possible?
class classB;
class classA
{
friend class classB;
friend ostream & operator<<(ostream&, const classA&);
void operator=(const classA&);
int altitude;
char code;
string area;
};
class classB
{
friend ostream& operator<<(ostream&, const classB&);
friend istream& operator>>(istream&, classB&);
public:
void operator=(const classB&);
void sort();
private:
classA* dataVals[30];
};
I am certain my overload functions are written correctly. We were given the basics of overloaded operators and the directions I just provided and that is all.