Code:#include <iostream> using namespace std; class Fraction { protected: int num; int denom; public: Fraction() : num(1), denom (1) { } Fraction(int top, int bottom): num(top), denom(bottom) { //check for divide by zero error if (denom == 0) { cout << "Divide by zero error, setting denominator equal to 1" << endl; denom = 1; } } int reduce(int p, int q) { int r; return ((r=p%q)==0)? q:reduce(q,r); } void showdata() { int gcd; gcd = reduce(num,denom); num /= gcd; denom /= gcd; if (num != 0) cout << num << "/" << denom << endl; } // overloaded addition Fraction operator + (Fraction)const; //overloaded minus Fraction operator - (Fraction f2) const; //overloaded multiplication Fraction operator * (Fraction f2) const; //overloaded division Fraction operator / (Fraction f2) const; }; class Mixed : public Fraction { private: int whole; public: Mixed(int w, int t, int b): whole(w), Fraction(t, b) }; // Actual overloaded fraction definitions Fraction Fraction::operator + (Fraction f2) const { int numtemp, denomtemp; //Fraction temp; numtemp = (num*f2.denom) + (denom * f2.num); denomtemp = (denom * f2.denom); return Fraction(numtemp, denomtemp); } Fraction Fraction :: operator - (Fraction f2) const { int numtemp, denomtemp; numtemp = (num*f2.denom) - (denom * f2.num); denomtemp = (denom * f2.denom); return Fraction(numtemp, denomtemp); } Fraction Fraction :: operator * (Fraction f2) const { int numtemp, denomtemp; numtemp = (num * f2.num); denomtemp = (denom * f2.denom); return Fraction(numtemp, denomtemp); } Fraction Fraction :: operator / (Fraction f2) const { int numtemp, denomtemp; numtemp = (num * f2.denom); denomtemp = (denom * f2.num); return Fraction(numtemp, denomtemp); } int main() { //Fraction fract1, answer; //Fraction fract2 (1,0); Mixed m1(1,3,4); //answer = fract1 + fract2; //m1.showwhole(); answer.showdata(); //answer = fract1 - fract2; //answer.showdata(); //answer = fract1 * fract2; //answer.showdata(); //answer = fract1 / fract2; //answer.showdata(); return 0; }

without the inheritance mixed.. EVREYTHING works perfectly.. even witht he interited class without the public part, it compiles with no problem. its only when i add the public part im getting a problem. does it have to do with the constructor?

can u have a constructor in an inherited class?