August 2012
Intermediate to advanced
976 pages
30h 17m
English
Now that the data members of Sales_data are private, our read, print, and add functions will no longer compile. The problem is that although these functions are part of the Sales_data interface, they are not members of the class.
A class can allow another class or function to access its nonpublic members by making that class or function a friend. A class makes a function its friend by including a declaration for that function preceded by the keyword friend:
class Sales_data {// friend declarations for nonmember Sales_data operations addedfriend Sales_data add(const Sales_data&, const Sales_data&);friend std::istream &read(std::istream&, ...
Read now
Unlock full access