Feb 22, 2016 at 8:55pm UTC
Can't figure out how to fix this, any help appreciated! Getting the error
expected unqualified-id before ‘public ’
I tried commenting out
void reduce(); and recompiling and gave me the same error
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class Rational
{
private :
//the numerator and denominator
void reduce();
int num, den;
};
void reduce();
public :
//accessors
int get_numerator() { return num; }
int get_denominator() { return den; }
int num, den;
Last edited on Feb 22, 2016 at 8:56pm UTC
Feb 22, 2016 at 8:58pm UTC
why are your stuff outside the class?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class Rational
{
private :
//the numerator and denominator
void reduce();
int num, den;
public :
//accessors
int get_numerator() { return num; }
int get_denominator() { return den; }
int num, den;
};
void reduce();
Im not sure why you have 2 functions named reduce and one of them is outside the class.
And Im not sure why you're creating
int num, den;
twice
Last edited on Feb 22, 2016 at 9:00pm UTC
Feb 23, 2016 at 1:25am UTC
Hi,
Do you have -std+c++11 or -std=c++14 when you compile ? Your compiler probably has the capability, just it's not being enabled.