using namespace std int main cfw use the default constructor to declare an fraction object frac1">

main-7.cpp - #include"fraction.h#include using...

Info icon This preview shows page 1. Sign up to view the full content.

#include "fraction.h" #include <iostream> using namespace std; int main() { // use the default constructor to declare an fraction object, frac1 Fraction frac1; // use the >> operator to read from keyboard and assign numerator and denominator values for frac1, // input numerator value 3, denominator value of 10 cin>>frac1; // use the << operator to display frac1 cout<<"Fraction 1: "<<endl; cout<<frac1<<endl; // declare a second fraction object, frac2, using the copy constructor and pass frac1 as the parameter Fraction frac2(frac1); // use the SetDenominator method to change the denominator of frac2 to 5 frac2.SetDenominator(5);
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '08
  • Staff
  • Computer Science, Method, Fraction, Subroutine, Mathematical notation

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern