So I've been working with classes for a while. After fiddling around, I came up with two instances of code that pretty much did the same thing. I wanted one to be using a member function and the other to be non member function. It compiles fine, but it doesn't link. For the life of me I can't figure out what's wrong.

Code:#include <iostream> using namespace std; class Fraction { public: Fraction(); Fraction( const Fraction& frOld ); Fraction( int iOld ); Fraction( int, int ); ~Fraction(); int getNum(); void setNum( int iOld ); int getDenom(); void setDenom( int iOld ); void print() const; int compare( Fraction ); private: int iNum; int iDenom; }; Fraction::Fraction() { iNum = 0; iDenom = 1; } Fraction::Fraction( const Fraction& frOld ) { iNum = frOld.iNum; iDenom = frOld.iDenom; } Fraction::Fraction( int iA, int iB ) { iNum = iA; if ( iB ) { iDenom = iB; } else { iDenom = 1; } } Fraction::Fraction( int iOld ) { iNum = iOld; if ( iOld ) { iDenom = iOld; } else { iDenom = 1; } } Fraction::~Fraction() { cout << "\nDestruction -- Clean out one Fraction object!" << endl; } int Fraction::getNum() { return iNum; } void Fraction::setNum( int iOld ) { iNum = iOld; return; } int Fraction::getDenom() { return iDenom; } void Fraction::setDenom( int iOld ) { if ( iOld ) { iDenom = iOld; } else { iDenom = 1; } return; } void Fraction::print() const { cout << "\n\tiNum: " << iNum << "\n\tiDenom: " << iDenom << endl; return; } void printFractionArray( Fraction frAry[], int iSize ) { for ( int i = 0; i < iSize; i++ ) { cout << "\nFraction frAry[ " << i <<" ] : " << "\n\t" << frAry[ i ].getNum() << "\n\t" << frAry[ i ].getDenom(); } return; } int compare( Fraction frA , Fraction frB ) { int iZ; double dFrA; double dFrB; double dNum1 = frA.getNum(); double dDenom1 = frA.getDenom(); double dNum2 = frB.getNum(); double dDenom2 = frB.getDenom(); dFrA = dNum1 / dDenom1; dFrB = dNum2 / dDenom2; if ( dFrA > dFrB ) iZ = 1; else if ( dFrA < dFrB ) iZ = -1; else iZ = 0; return iZ; } int main () { int iX; int iY; int iZ; Fraction frA; Fraction frB; cout << "CIS 25 - C++ Programming" << endl << "Laney College" << endl << "Amol Mundayoor\n" << endl << "Assignment Information --" << endl << " Assignment Number: Lab 7, " << endl << " Postlab Exercise #3" << endl << " Written by: Amol Mundayoor" << endl cout << "Fraction #I --" << "\n\tEnter Numerator : "; cin >> iX; frA.setNum(iX); cout << "\n\tEnter Denominator : "; cin >> iY; frA.setDenom(iY); cout << "Fraction #II --" << "\n\tEnter Numerator : "; cin >> iX; frB.setNum(iY); cout << "\n\tEnter Denominator : "; cin >> iY; frB.setDenom(iY); cout << "Fraction I " << endl; frA.print(); cout << "Fraction II " << endl; frB.print(); iZ = frA.compare(frB); cout << "\nThe result of comparing Fraction #1 to Fraction #2 : " << iZ << endl; return 0; }Any help would be greatly appreciatedCode:#include <iostream> using namespace std; class Fraction { public: Fraction(); Fraction( const Fraction& frOld ); Fraction( int iOld ); Fraction( int, int ); ~Fraction(); int getNum(); void setNum( int iOld ); int getDenom(); void setDenom( int iOld ); void print() const; int compare( Fraction ); private: int iNum; int iDenom; }; Fraction::Fraction() { iNum = 0; iDenom = 1; } Fraction::Fraction( const Fraction& frOld ) { iNum = frOld.iNum; iDenom = frOld.iDenom; } Fraction::Fraction( int iA, int iB ) { iNum = iA; if ( iB ) { iDenom = iB; } else { iDenom = 1; } } Fraction::Fraction( int iOld ) { iNum = iOld; if ( iOld ) { iDenom = iOld; } else { iDenom = 1; } } Fraction::~Fraction() { cout << "\nDestruction -- Clean out one Fraction object!" << endl; } int Fraction::getNum() { return iNum; } void Fraction::setNum( int iOld ) { iNum = iOld; return; } int Fraction::getDenom() { return iDenom; } void Fraction::setDenom( int iOld ) { if ( iOld ) { iDenom = iOld; } else { iDenom = 1; } return; } void Fraction::print() const { cout << "\n\tiNum: " << iNum << "\n\tiDenom: " << iDenom << endl; return; } void printFractionArray( Fraction frAry[], int iSize ) { for ( int i = 0; i < iSize; i++ ) { cout << "\nFraction frAry[ " << i <<" ] : " << "\n\t" << frAry[ i ].getNum() << "\n\t" << frAry[ i ].getDenom(); } return; } int Fraction::compare( Fraction frB ) { int iResult; double dFrA; double dFrB; double dNum1 = iNum; double dDenom1 = iDenom; double dNum2 = frB.getNum(); double dDenom2 = frB.getDenom(); dFrA = dNum1 / dDenom1; dFrB = dNum2 / dDenom2; if ( dFrA > dFrB ) iResult = 1; else if ( dFrA < dFrB ) iResult = -1; else iResult = 0; return iResult; } int main () { int n; int iX; int iY; int iZ; int compare(Fraction FrA, Fraction FrB); Fraction frA; Fraction frB; cout << "CIS 25 - C++ Programming" << endl << "Laney College" << endl << "Amol Mundayoor\n" << endl << "Assignment Information --" << endl << " Assignment Number: Lab 7, " << endl << " Postlab Exercise #3" << endl << " Written by: Amol Mundayoor" << endl cout << "Fraction #I --" << "\n\tEnter Numerator : "; cin >> iX; frA.setNum(iX); cout << "\n\tEnter Denominator : "; cin >> iY; frA.setDenom(iY); cout << "Fraction #II --" << "\n\tEnter Numerator : "; cin >> iX; frB.setNum(iX); cout << "\n\tEnter Denominator : "; cin >> iY; frB.setDenom(iY); cout << "Fraction I " << endl; frA.print(); cout << "Fraction II " << endl; frB.print(); iZ = compare (frA, frB); cout << "\nThe result of comparing Fraction #1 to Fraction #2 : " << iZ << endl; cout << endl; return 0; }

And is the "this" pointer and "->" totally different entities?

And my professor also had told us to modify a fraction addition program so that we can add two "rectangle fractions"

"When adding two RectangleFraction objects, the result is another RectangleFraction object that has the length to be the sum of the two (2) lengths and the width to the sum of the two (2) widths"

I don't get what he means by that. How would I go about doing that?