[cs13001] FW: Friend Function definition
Mikhail Nesterenko
mikhail at cs.kent.edu
Mon Mar 10 13:15:38 EDT 2014
>
> In class we went over friend functions but we were missing a
> definition for the mybday example from the slides. What is the
> definition for the friend function example for mybday?
>
declaration inside class:
friend bool equal(const Date&, const Date&);
outside function definition:
bool equal(const Date& left, const Date& right){
if(left.month == right.month &&
left.day == right.day &&
left.year == right.year)
return true;
else
return false;
}
invocation:
Date d1.set(3,10,2014);
Date d2.set(3,10,2015);
if(equal(d1,d2))
cout << "Dates match!" << endl;
Thanks,
--
Mikhail
More information about the cs13001
mailing list