# hi I NEED HELP

• 11-06-2011
hi I NEED HELP

• Create a class Rational using the UML diagram below.

 Rational Numerator: int Denominator: int Rational ( ) Rational (int, int) ~Rational () Int: getnumerator () Int: getdenominator () Setnumerator (int) Setdenominator (int )

• Implement the following function as a friend function of the rational class
• Print Rational (Rational & )

• Create a main function that instantiates 2 objects (object 1, object2) using the primary constructor and 1 object (object3) using the default constructor.
• Perform the following operations on the objects created:
• Set the numerator of object3 to 34
• Set the denominator of object2 to 89
• Set the numerator of object1 to 5
• Confirm that the operations were successful by displaying the result of the following functions Object1.getnumerator
• Object2.getdenominator
• Object3.getnumerator

Call the Print Rational function to display each rational.
• 11-06-2011
grumpy
• 11-06-2011
THANKS, I DO HAVE PIECES OF CODES, HERE
Code:

```//HEADER FILE #include<iostream> using namespace std; class rational {     //friend print rational(rational & m); public:     rational();     rational(int,int);     ~rational();     int getnumerator(void);     int getdenominator(void);     void setnumerator(int);     void setdenominator(int);     private:     int denominator;     int numerator; }; rational::rational() {     numerator=0;     denominator=0; } rational::rational(int num,int dem) {     numerator=num;     denominator=dem; } rational::~rational() {     cout<<"we are in the destructor function"<<endl; } int rational::getnumerator(void) {     return numerator; } int rational::getdenominator(void) {     return denominator; } void rational::setnumerator(int new_numerator) {     numerator=new_numerator; } void rational::setdenominator(int new_denominator) {     denominator=new_denominator; } // .CPP FILE MAIN #include<iostream> using namespace std; #include"rat.h" int main() { rational object3,object2,object1; object3.setnumerator(54); object2.setdenominator(89); object1.setnumerator(5); cout<<object1.getnumerator<<endl; cout<<object2.getdenominator<<endl; cout<<object3.getnumerator<<endl;     return 0; } THANKS GRUMPY.```
• 11-06-2011
i keep on getting a one for output for all objects
• 11-06-2011
do i of to have these?
Code:

``` rational add(rational r) { rational l; int a = l.getnum(); int b = l.getden(); int c = r.getnum(); int d = r.getden(); rational result = ((a * d + b * c) / (b * d)); return result; }```
for it to work?

am reading some books and am not understanding how rational works really. sad!
• 11-06-2011
:(........:(
• 11-06-2011
Salem
cout<<object1.getnumerator<<endl;

Compare with

cout<<object1.getnumerator()<<endl;