TrashCan operator overloading homework

My assignment for class was to create a class called trashcan and overload it. i created the program, but im having trouble running it because i have some errors i do not know how to to correct. i'll post my code to see the if anyone can help with it
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "TrashCan.h"
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main();
class TrashCan
{
	friend ostream& operator << (ostream& const TrasnCan &,const TrashCan & );
	friend istream& operator >> (istream input&,const TrashCan &,const TrashCan & );
	friend bool operator == (const TrashCan &, const TrashCan &);
	friend TrashCan operator - (const TrashCan &, const TrashCan &);
	friend TrashCan operator + (const TrashCan &, const TrashCan &);
	friend TrashCan operator * (const TrashCan &, const TrashCan &);
	friend TrashCan operator / (const TrashCan &, const TrashCan &);
private:
	int my_size;
	int array[10][10];
	int my_Contents;
public:
	TrashCan(int);
	TrashCan(int,int);
	bool operator != (const TrashCan &) const;
	TrashCan operator + (const TrashCan &) const;
	const TrashCan & operator = (const TrashCan &);
    TrashCan::TrashCan(const TrashCan &);
    TrashCan( int size, int contents );
     void setSize( int size );
     void addItem( );
     void empty( ); 
     void cover( );
     void uncover( );
     void printCan( );
     bool myIsCovered;
     int my_Size;
     int my_Contents;
};
TrashCan TrashCan:: operator = (const TrashCan & a) const
{
	TrashCan temp(my_size, my_Contents);

	for (int i = 0; i < a.my_size; i++)
		for (int j = 0; j < a.my_size; j++)
            temp.array[i][j] = a.array[i][j] + array[i][j];

    return temp;
} 
TrashCan operator - (const TrashCan & a, const TrashCan & b)
{
    TrashCan temp(int my_size, int my_Contents);

    for (int i = 0; i < a.my_size; i++)
        for (int j = 0; j < a.my_size; j++)
           temp.array[i][j] = a.array[i][j] - array[i][j];

    return temp;
}

TrashCan operator + (const TrashCan & a, const TrashCan & b)
{
    TrashCan temp(int my_size, int my_Contents);

    for (int i = 0; i < a.my_size; i++)
        for (int j = 0; j < a.my_size; j++)
            temp.array[i][j] = a.array[i][j] - array[i][j];

    return temp;
}
TrashCan operator * (const TrashCan & a, const TrashCan & b)
{
    TrashCan temp(int my_size, int my_Contents);

    for (int i = 0; i < a.my_size; i++)
        for (int j = 0; j < a.my_size; j++)
            temp.array[i][j] = a.array[i][j] - array[i][j];

    return temp;
}
TrashCan operator / (const TrashCan & a, const TrashCan & b)
{
    TrashCan temp(int my_size, int my_Contents);

    for (int i = 0; i < a.my_size; i++)
        for (int j = 0; j < a.my_size; j++)
            temp.array[i][j] = a.array[i][j] - array[i][j];

    return temp;
}

TrashCan::TrashCan(){
	myIsCovered = false;
	my_Size = 0;
	my_Contents = 0;
}

TrashCan::TrashCan( int size ) {
	myIsCovered = false;
	my_Size = size;
	my_Contents = 0;
}

TrashCan::TrashCan( int size, int contents ) {
	myIsCovered = false;
	my_Size = size;
	my_Contents = contents;
}

void TrashCan::setSize( int size ) {
	my_Size = size;
}

void TrashCan::addItem( ) {
	my_Contents = my_Contents + 1;
}
	
void TrashCan::empty( ) {
	my_Contents = 0;
}

void TrashCan::cover( ) {
	myIsCovered = true;
}

void TrashCan::uncover( ) {
	myIsCovered = false;
}

void TrashCan::printCan( ) {
	cout << "A TrashCan with a size=" << my_Size << " and containing " << my_Contents << " piece";
	if (my_Contents != 1) {
		cout << "s";
	}
	cout << " of trash" << endl;
}




but im having trouble running it because i have some errors i do not know how to to correct.


It would be a lot easier if you post the compiler output in full (the errors) - then you might get some replies.

Last edited on
Topic archived. No new replies allowed.