Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(C++) Here is the programming problem: Define a class called Fraction that has 2 private members that represent the numerator and denominator respectively. They will

(C++)

Here is the programming problem: Define a class called Fraction that has 2 private members that represent the numerator and denominator respectively. They will be represented as integers. Include a constructor and a public void function called print that prints out the fraction. (For example, if the numerator is 3 and the denominator is 5, print provides as output 3/5.) Include the class in a program that prints out the fraction 3/5. My code so far is listed below, but I am not able to start the program. I believe the problem resides with the output I am trying to do with "print". Not sure what should be there instead.

#include using namespace std;

class Fraction { public: void print(); private: int num; int dem; };

void Fraction::print() { cout << num << "/" << dem << endl; }

int main() { int num = 0; int dem = 1; void print();

cout << "Enter numerator: "; cin >> num; cout << "Enter demoninator: "; cin >> dem;

cout << "Fraction is: " << print << endl;

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Shouhong Wang, Hai Wang

1st Edition

1612330150, 978-1612330150

More Books

Students also viewed these Databases questions

Question

Explain why the credit crisis caused concerns about systemic risk.

Answered: 1 week ago

Question

Who is the target audience (or audiences)?

Answered: 1 week ago

Question

=+what kinds of policies and practices should be developed?

Answered: 1 week ago

Question

=+ Of the HR issues mentioned in the case,

Answered: 1 week ago