ccplusplus.com
Learn C, C++ Concepts
Thursday, December 29, 2011
proxy design pattern c++ examples
/******************************************************************* * File : procy-pattern.cpp (proxy design pattern c++ examples) * Author : Saurabh Gupta * Description : Proxy allows one object to stand for something else. * So whilst you think you are dealing with one object, * you are actually dealing with something else. * In this example, CProxyPattern stands for cout. * Date : PM 05:45 29 December 2011 * Source : http://www.ccplusplus.com/2011/07/design-pattern-guide-with-example-and.html * Note : ******************************************************************/ #include <iostream> #include <string> using namespace std; class CProxyPattern { public: void write(const string & str) const { cout << str; } }; void helloworld(const CProxyPattern & cout) { cout.write("Hello world!\n"); } int main() { helloworld(CProxyPattern()); return 0; } /* * OUTPUT * [sgupta@rhel6x64 interpreter]$ c++ interpreter-pattern.cpp -o interpreter-pattern [sgupta@rhel6x64 interpreter]$ ./interpreter-pattern Hello world! [sgupta@rhel6x64 interpreter]$ */
See Also:
Design pattern Concept and Sample Codes
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment