[Assorted-commits] SF.net SVN: assorted: [667] sandbox/trunk/src/cc/friends.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-04-21 03:29:22
|
Revision: 667 http://assorted.svn.sourceforge.net/assorted/?rev=667&view=rev Author: yangzhang Date: 2008-04-20 20:29:22 -0700 (Sun, 20 Apr 2008) Log Message: ----------- added friend test Added Paths: ----------- sandbox/trunk/src/cc/friends.cc Added: sandbox/trunk/src/cc/friends.cc =================================================================== --- sandbox/trunk/src/cc/friends.cc (rev 0) +++ sandbox/trunk/src/cc/friends.cc 2008-04-21 03:29:22 UTC (rev 667) @@ -0,0 +1,17 @@ +// Demonstrates that you don't have to "know" a friend class. + +class C { + friend class F; + private: int x; +}; + +class F { + public: int x(C c) { return c.x; } +}; + +int +main() { + C c; + F f; + return f.x(c); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |