Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views1 page

345 Notes24

345 notes

Uploaded by

Hanarene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

345 Notes24

345 notes

Uploaded by

Hanarene
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 1
«In principle, private and protected members of a class cannot be accessed from outside the class in which they are declared. - A friend (function or class) of a class may access the members designated as private or protected. + Friends are functions/methods or classes declared as such within a class. + Friends are not members, so they are not inherited from a superclass. » Widely criticized for being a “rogue feature”: » Makes the language more complex to implement. + Breach of the information hiding principle. + If overused, creates a proliferation of exceptions to information hiding, and thus confusion in the design. (pt osaeit EeewrEunetion: cRectangle duplicate (CRectangle rectparam) include cRectangle rectres; using namespace std; rectres width = ractparan.wideht2; rectres.neight = rectparam.height*2 class CRectangle { return (rectres): private: int width, height; ae. putes cRectangle rect, rect rect.set_values (2,3) void set_values (int, int); recth = dglicate (neat); fea () {return (width * height) ;} cout << rectb.area(); ‘friend CRectangle duplicate (CRectangle); ——ceturn 0; ye A Free Function neds +0 be otriend. 40 OKESS AdtriloureS

You might also like