### Problem with function undeclared error

In the function for overloading the >> operator I am getting this error:
84`rationalize_number' undeclared (first use this function)

this is the function:
 ``12345678910111213141516171819`` ``````istream& operator >>(istream& in, Rational& rational1) { char tempChar; int numerator = rational1.numerator; int denominator = rational1.denominator; in >> tempChar; if(tempChar == '(') { in >> rational1.numerator >> tempChar; } if(tempChar == ',') { in >> rational1.denominator >> tempChar; } rationalize_number(numerator,denominator); cout << rational1; }``````

Hereis the whole program:

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134`` ``````#include #include using namespace std; class Rational { public: Rational(); Rational(int numerator1); Rational(int numerator1, int denominator1); friend Rational operator -(Rational rational1, Rational rational2); friend Rational operator +(Rational rational1, Rational rational2); friend Rational operator /(Rational rational1, Rational rational2); friend Rational operator *(Rational rational1, Rational rational2); friend bool operator <(Rational rational1, Rational rational2); friend bool operator >(Rational rational1, Rational rational2); friend bool operator ==(Rational rational1, Rational rational2); friend bool operator >=(Rational rational1, Rational rational2); friend ostream& operator <<(ostream& out,Rational& rational1); friend istream& operator >>(istream& in, Rational& rational1); private: int numerator; int denominator; void rationalize_number(int& numerator, int& denominator); }; int main() { Rational test1(24,6), test2(24); Rational test4; cout << test1<< endl; cout << test2<< endl; cout << test4<> test4; cout << endl; cout << test4 << endl; system("pause"); } Rational::Rational() : numerator(0), denominator(1) { //empty body } Rational::Rational(int numerator1) { numerator = abs(numerator1); denominator = 1; } Rational::Rational(int numerator1, int denominator1) { rationalize_number(numerator1,denominator1); numerator = numerator1; denominator = denominator1; } ostream& operator <<(ostream& out,Rational& rational1) { out << rational1.numerator <<"/"<>(istream& in, Rational& rational1) { char tempChar; int numerator = rational1.numerator; int denominator = rational1.denominator; in >> tempChar; if(tempChar == '(') { in >> rational1.numerator >> tempChar; } if(tempChar == ',') { in >> rational1.denominator >> tempChar; } rationalize_number(numerator,denominator); cout << rational1; } void Rational::rationalize_number(int& numerator, int& denominator) { int countDenom; int countNum; //cout << numerator<< "/" << denominator << endl; if(numerator >= denominator) { for (countDenom = denominator; countDenom >= 2; countDenom--) { //cout << "in for" < numerator) { for (countNum = numerator; countNum >= 2; countNum--) { if(denominator%countNum == 0 && numerator%countNum == 0) { denominator = denominator/countNum; numerator = numerator/countNum; } //else //{ // ; //} } } }``````
Topic archived. No new replies allowed.