"Overloading" (at least in C++) means that you have more than one function with the same name. In this case, you have three different constructors, but they all have the same name.
The difference is the number and type of arguments it accepts.
The first takes no arguments, so it is the default constructor.
The second takes a list of values to initialize the class, so it is an initializing constructor.
The last takes a reference to another object of the same type (or 'class'), and copies its values, so it is a copy constructor.
In the body of the default constructor, you gave all your object's variable fields default values.
In the body of the initializing constructor, use the arguments to assign values to your object's variable fields.
Keep in mind that since the argument and the field names are identical, you must use this to refer to the object's fields:
this->Donation = Donation;
Hope this helps.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Just a quick glance it looks OK.
The insertion operator prototype should list its second argument as const:
ostream& operator << (ostream& out, const Contributor& InContributor)
What makes one Contributor less than another? Answer that and you can write the contents of your < operator.
Hope this helps.
[edit] Oh yeah, your assignment operator's insides should look very much like your copy constructor's insides.
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
When you overload stream operators such that they take two arguments, you have to declare them friend or they, like any other foreign object, will not be allowed to tinker with the object's internals.
class foo
{
private:
int i;
...
public:
friend ostream& operator << ( ostream&, const foo& );
};
ostream& operator << ( ostream& outs, const foo& f )
{
ostream << f.i << endl; // or whatever
}
Sorry about that. I should have noticed and warned you about it.
:$
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229