Hey. I'm coding an abstract data type for a rational number. I have been attempting to code the operator overload for insertion, but when doing so i recieve errors telling me that the objects members are private (and thus, cannot be accessed) despite it being a friend function. If someone may have any ideas about what may be wrong here, I would of course appreciate it

Code:
```ostream& operator <<(ofstream& outs, const rational& temp){
if (!temp.positive)
outs << "-";
outs << temp.ratNum[0] << "/" << temp.ratNum[1];
return outs;
}```
Code:
```#include <iostream>
#include <fstream>

using namespace std;
const int size = 2;
class rational{

friend rational operator+(const rational&, const rational&);
friend rational operator-(const rational&, const rational&);
friend rational operator*(const rational&, const rational&);
friend rational operator/(const rational&, const rational&);
void friend subtractRational(rational&, rational&, rational&);
void friend multRational(rational, rational, rational&);
void friend divRational(rational, rational, rational&);
void friend lcd (rational&, rational&);
void friend gcf(rational&);
friend ostream& operator<<(ostream&, const rational&);
friend istream& operator>>(istream&, const rational&);

public:
void output();
rational operator =(const rational&);
rational(int);
rational(void);					 // void constructor
rational(int, int); 	// constructor for creating rational number
~rational();				// destructor
rational(const rational&);

private:
int *ratNum;
bool positive;
};```

2. The signature says:

Code:
`friend istream& operator>>(istream&, const rational&);`
Surely you want to modify the object you are inputting to?

Another problem with operator<<:

Code:
```//friend declaration:
friend ostream& operator<<(ostream&, const rational&);

//implementation
ostream& operator <<(ofstream& outs, const rational& temp) {...}```
Naturally that function isn't a friend of rational.

I also hope ratNum, which is an array of two integers (?), is not going to be dynamically allocated?

3. Originally Posted by anon
The signature says:

Code:
`friend istream& operator>>(istream&, const rational&);`
Surely you want to modify the object you are inputting to?

I also hope ratNum, which is an array of two integers (?), is not going to be dynamically allocated?
edit: thanks a lot was able to make a lot of progress due to the things you pointed out. Please forgive my lack of complete understanding of this subject - I am enrolled in a course where we will be studying these things in the future, but I am looking ahead at future material due to eagerness.