I get about 100 errors when i compile this program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include "rational.h"
using namespace std;



#ifndef MIXEDNUMBER
#define MIXEDNUMBER

class MixedNumber{
private:
    int left;
    Rational right;
    void reduce(); // example: first calls proper(), then, for example, changes 4 6/8 to 4 3/4 
    void proper(); // example: changes 5 4/3 to 6 1/3
public:
    MixedNumber();
    MixedNumber (int I, const Rational& R);
    MixedNumber(const MixedNumber& M);

    int getLeft ()const;
	Rational getRight ()const;

    void setLeft(int I);
    void setRight(const Rational& R);
    void set(int I, const Rational& R);

    operator double() const;
    operator Rational() const;

    friend MixedNumber operator + (const MixedNumber& m, const MixedNumber& n);
    friend MixedNumber operator - (const MixedNumber& m, const MixedNumber& n);
    friend MixedNumber operator * (const MixedNumber& m, const MixedNumber& n);
    friend MixedNumber operator / (const MixedNumber& m, const MixedNumber& n);
    friend bool operator < (const MixedNumber& m, const MixedNumber& n);
    friend bool operator > (const MixedNumber& m, const MixedNumber& n);
    friend bool operator == (const MixedNumber& m, const MixedNumber& n);
    friend ostream& operator << (ostream& os, const MixedNumber& m);
    friend istream& operator >> (istream& is, MixedNumber& m);
};
#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>

#ifndef RATIONAL
#define RATIONAL

class Rational {
private:
	int num, den;
	
public:
	Rational ( ) : num(0), den(1) { }
	Rational ( int n) : num(n), den(1) { }
	Rational (int n, int d) : num(n), den(d){if (d==0) den=1;}
	Rational ( const Rational& r) : num(r.num), den(r.den) { }
	int getNum ( ) const; 
	int getDen ( ) const; 

	void setNum(int n);
	void setDen(int d);
	void set(int n, int d);
	friend Rational operator +(const Rational& r, const Rational& t);
	friend Rational operator -(const Rational& r, const Rational& t);
	friend Rational operator *(const Rational& r, const Rational& t);	
	friend Rational operator /(const Rational& r, const Rational& t);	
	friend ostream& operator << (ostream& outs, const Rational& r);
    friend istream& operator >> (istream& ins, Rational& r);
	bool isPositive( )const; 
	bool isNegative( )const;	
	friend void reduce( );
};
#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "rational.h"
#include "mixednumber.h"
using namespace std;




int main(){
	MixedNumber x(33/4);
	MixedNumber y(2,1/3);
	MixedNumber z(x);
	Rational;
	x.setLeft(2);
	x.setRight(2/3);
	x.set(2,2/3);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "rational.h"
#include "mixednumber.h"
using namespace std;


MixedNumber ( ) : left(0),right(0)
MixedNumber (int I, const Rational& R):left(I),right(R){}
MixedNumber(const MixedNumber& M):left(m.left),right(m.right){}

	int getLeft ()const{
		return left;}
	Rational getRight ()const{
		return right;}


	void setLeft(int I){
		left=I;}
	void setRight(const Rational& R){
		right=R;}
	void set(int I, const Rational& R){
		left=I;
		right=R;
	}

	operator double() const;
    operator Rational() const;
	/*void proper(){*/



	 MixedNumber operator + (const MixedNumber& m, const MixedNumber& n){
		MixedNumber temp;
		temp.left=m.left+n.left;
		temp.right=m.right+n.right;
		temp.proper;
		return temp;}
	 MixedNumber operator - (const MixedNumber& m, const MixedNumber& n){
		MixedNumber temp;
		temp.left=m.left-n.left;
		temp.right=m.right-n.right;
		temp.proper;
		return temp;}
	 MixedNumber operator * (const MixedNumber& m, const MixedNumber& n){
		MixedNumber temp;
		temp.left=m.left*n.left;
		temp.right=m.right*n.right;
		temp.proper;
		return temp;}
	 MixedNumber operator / (const MixedNumber& m, const MixedNumber& n){
		MixedNumber temp;
		temp.left=m.left/n.left;
		temp.right=m.right/n.right;
		temp.proper;
		return temp;}
	 bool operator < (const MixedNumber& m, const MixedNumber& n){
		if (m<n)
			return true;
		else false;
	}
	 bool operator > (const MixedNumber& m, const MixedNumber& n){
		if (m>n)
			return true;
		else false;
	}
	 bool operator == (const MixedNumber& m, const MixedNumber& n){
		if (m==n)
			return true;
		else false;
	}
	 ostream& operator << (ostream& os, const MixedNumber& m){
		 cout << endl;
		 os << m.left << m.right << endl;
		 return os;
	 }
	 istream& operator >> (istream& is, MixedNumber& m){
		 cout << "Enter whole number" >> is >> left >> endl;
		 cout << "Enter rational number" >> ins >> endl;
		 return is, ins;
	 }



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
#include "rational.h"
using namespace std;




Rational ( ) : num(0), den(1) { }
	Rational ( int n) : num(n), den(1) { }
	Rational (int n, int d) : num(n), den(d){if (d==0) den=1;}
	Rational ( const Rational& r) : num(r.num), den(r.den) { }


int getNum ( ) const {return num;}
int getDen ( ) const {return den;}
void setNum(int n){num=n;}
	void setDen(int d){
		if(d==0) den=1;
			else den=d;}
	void set(int n, int d) {num=n; den=d;}
	void reduce();
	Rational operator +(const Rational& r){
		Rational temp;
		temp.num=r.num*t.den+r.den*t.num;
		temp.den=r.den*t.den;
		temp.reduce();
		return temp;}

	Rational operator -(const Rational& r, const Rational& t){
		Rational temp;
		temp.num=num*r.den-den*r.num;
		temp.den=den*r.den;
		temp.reduce();
		return temp;}

    Rational operator *(const Rational& r, const Rational& t){
		Rational temp;
		temp.num=num*r.num;
		temp.den=den*r.den;
		temp.reduce();
		return temp;}

	Rational operator /(const Rational& r, const Rational& t){
		Rational temp;
		temp.num=num*r.den;
		temp.den=den*r.num;
		temp.reduce();
		return temp;}

	bool isPositive( )const { 
		if(num*den > 0) return true;
		return false;
	}

	bool isNegative( )const{ 
		if(num*den < 0) return true;
		return false;
	}

	/*cout << num << "/" << den << endl;}*/

	ostream& operator << (ostream& outs, const Rational& R){
	outs << r.num << r.den << endl;
	return outs;
	}

	istream& operator >> (istream& ins, Rational& r){
	char ch;
	cout <<" Enter a numerator, then enter a '/', then enter a denominator"; ins >> r.num >> ch >> r.den << endl;
	return ins:
	}

	/*{ char  ch;
	cin >> num >> ch >> den;
	reduce( );}*/



int gcd( int p, int q)
{if (p==0) return q;
return gcd(q%p,p);}

void reduce( )
{int factor =gcd(num, den);
num/=factor; den/=factor;
if (den < 0) {
	num=-num;
	den=-den;}
}


I would include a list of my errors, but it is about 100 in number. Too much to list in this post along with the long bits of code.
I think it would be best if you posted the errors, or at least used an online pastebin.
Topic archived. No new replies allowed.