-
Rational Numbers
Hi, i have to create a program for school. I am not asking you to write it or even start it for me, but i am asking you to push me in the right direction so i know where to begin. We have to have the user input the numerator and denominator to create a fraction. They must create two fractions and they must be added, subtracted, timed, and divided. We are talking about objects, classes, structs, and etc. in class however, i dont understand this. What will be the puropse of objects and stuff in a program like this and how do i even begin? I only understand functions and stuff. I appericate the help
-
Well, you could have a Fraction class with both numerator and denominator as member variables and overload arithmetic operators to mimic math behavior.
-
I was going to say something like what Desolation said, but also have a look at these links for classes and structures.
Classes
Structures
When I first learned about classes (and still learning) I thought of them as collections of data types and functions that use those data types. Structures can be thought of as a collection of data types. There can be a lot more too them though, that's just an abstract look at it.