basically non-member functions don't have access to privat members:
today.month = 1;//EROR today.month is a private field.
Friend functions have access to all fields in class.
1 2 3 4 5 6
bool equal(const Date& left, const Date& right);
return ( (left.year == right.year) && (left.month == right.month) && (left.day == right.day) );
//previous statement wont cause error on left.year and similar
//because it is an friend function
In some cases you have to use friend functions (i.e. overloading operator<< for outputting your data).
equal() function returns true if left argument equals to right. So if(equal(date1, date2)) means: "if dates are equal..."
It is better to overload operator== but looks like you didn't get to operator overloading yet.
Ok that makes more sense now. So would friend functions (in most cases) be a bad thing to use? Couldn't you usually just use an accessor instead of a friend function? I know there would be exceptions but I just mean in general.
Thanks for clarifying that! One more quick question, is a staticconst basically the same as const but is used in classes and is available to all methods of that class and also all objects? Basically like a global variable? Or am I misunderstanding?