I'm currently working on a project that simplifies and adds two user-defined fractions. The teacher specified that we use a function with the prototype:

Fraction addfractions(const Fraction& f1, const Fraction& f2)

My problem is, I can't find any information on this Fraction data type that he is making us use. None at all. Every C++ data type tutorial I've visited makes no mention of a Fraction type.

How does this "Fraction" data type work? Any info / links would be amazing.



Recommended Answers

All 3 Replies

Um, have you had practice dealing with user defined types such as classes or structs. If so, I suspect he wants to de declare a type called Fractions and do whatever you have to do be able to add two objects of type Fraction together using a function with the prototype provided.

To my knowledge there is no standard C++ class that declares a type called Fraction. I'm sure if you look on line you can find one written out if you really want to do so. But, if you don't already have the type available to you, because your teacher gave it to you or from a prior assignment, then I'd do it from scratch.

Ooooooh. I get it now. Thank you very much!

You need to write a Fraction class for this to work

using namespace std;

class Fraction
    int numerator;
    int denominator;

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.