Fraction Class

Hey guys i need some help. For some reason when im trying to do this header file for the fraction class, it says theres an error. Please help me out. Thank YOU!


#ifndef Point_H
#define Point_H

class Fraction
{
int num, den;
public:
Fraction();
Fraction(int,int);
Fraction(int);


Fraction(const Fraction&);
~Fraction();
static bool isValidDenom(int);
static Fraction create(int,int);
double toDecimal() const;
string toString() const;
};

#endif


Also, if someone could help me on how to start the .Cpp file to test all these that would be really appreciated! thank you
1) Please use code tags, to make your code usable:

http://www.cplusplus.com/articles/z13hAqkS/

2)
theres an error

It's flattering that you consider us so talented that we'll just be able to read your mind to find out what the error actually is. Sadly, despite modern advances in genetic engineering, telepathic programmers are still rare, so you'll have to go to the effort of actually telling us what error you're seeing.
Last edited on
Hmmm, first off, here are some pointers where you can improve the class:

Don't use the default private setting to define data members.

It's always nicer and best to explicitly state private:, followed by the data members.

Group your methods in a certain way:

- Constructors all in one group
- Destructor

- static methods

- methods

Also, don't forget to #include <string> in your header file as well as do this:

std::string (you can use: using namespace std; , but that's not considered good practice).

If you need more help, let me know at: sparkprogrammer@gmail.com

I'm actually a C++ tutor.

Hope I helped,
Joe
Topic archived. No new replies allowed.