Ok, so in class our newest program assignment is to overload +, -, *, /, =, and << operators.
I've written a class that handles Fractions and right now I am only trying to overload the + operator and the << operator. I figured once I accomplished this the rest would fall out easy.
I'm not sure what I've done wrong and I'm not the greatest are debugging and working in classes makes it that much more difficult. I am looking for a little direction here. If anyone could possible check my code and point in the right direction I would be truly thankful!
c:\documents and settings\family\my documents\visual studio 2010\projects\fractions\fractions\fractions.h(22): error C2143: syntax error : missing ';' before '&'
c:\documents and settings\family\my documents\visual studio 2010\projects\fractions\fractions\fractions.h(22): error C2433: 'ostream' : 'friend' not permitted on data declarations
c:\documents and settings\family\my documents\visual studio 2010\projects\fractions\fractions\fractions.h(22): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\family\my documents\visual studio 2010\projects\fractions\fractions\fractions.h(22): error C2061: syntax error : identifier 'ostream'
c:\documents and settings\family\my documents\visual studio 2010\projects\fractions\fractions\fractions.h(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\documents and settings\family\my documents\visual studio 2010\projects\fractions\fractions\fractions.h(23): error C2805: binary 'operator <<' has too few parameters
c:\documents and settings\family\my documents\visual studio 2010\projects\fractions\fractions\fractions.h(23): error C2333: 'Fractions::operator <<' : error in function declaration; skipping function body
It's giving me these errors associated with my << operator overload in the header. Any ideas?
Heck Ya! You guys are awesome. Thanks for the help. I got it running so know I can go back and overload the others.
Also, Disch, right now you are correct I am only handling one fraction for simplicity. My goal is to be able to have the user input multiple fractions to be added, subtracted, multiplied, divided, and checked to see if they equal each other or not.
Again, guys thanks for the help! I will try and post the completed code soon.
Also, Disch, right now you are correct I am only handling one fraction for simplicity. My goal is to be able to have the user input multiple fractions to be added, subtracted, multiplied, divided, and checked to see if they equal each other or not.
Right... but the class itself will only be one of those fractions. If the user enters mulitple fractions, each fraction will have it's own object.
1 2
Fractions a; // here's one fraction
Fractions b; // here's another one
a and b are both a "Fractions" -- but they each only represent a singular fraction.
Do you see what I mean? The class itself represents one fraction, so it should be singular Fraction.