C + + implementation of 23 design patterns

Source: Internet
Author: User

Before looking at head first design mode, a C + + version is implemented according to the code in the book (Java version in the book), and the code is uploaded in https://github.com/clpsz/ Book-hfdp-code.

At the time, because of limited capacity, there was no direct choice to see Gof's design pattern: The basis of reusable object-oriented software. In the last one months, I wrote a little QT program on Windows, had a little understanding of C + + and design patterns, and looked back at Gof's masterpiece and didn't feel so difficult. So take the time to read through the book, although the book has some C + + code, but basically is based on a specific scene, and many are not all, so I just by the way all of the patterns in the inside and put it on GitHub, the address is as follows https://github.com/ Clpsz/gof-design-patterns. All the code took me a little more than three days to write from Saturday onwards to this Tuesday morning.

All code is the demo version of this mode, there is no pre-set scene, no third-party library, using only the String,vector,map these STL, so directly native C + + can be compiled, my test environment for Ubuntu 12.04 64bit.

has been doing Linux development, so the C language is relatively familiar, intuitive feeling is C language good strong, high efficiency, less reliance, easy to run. Recently, a little C + + has been implemented, and the efficiency of development has been greatly improved, compared to C. Personal feeling when I use C + +, there are some very handy features:

  1. powerful STL can be used, such as vector,string,map and so on it is very comfortable to use. The
  2. function overload is so convenient that it is troublesome to have a different function name before, and sometimes have to use a number suffix such as foo1. The default value of the
  3. parameter, which is very convenient, is to add a default value directly to the parameters that are not changed frequently. The
  4. is programmed for the interface. This is an important principle of design patterns, which can be well achieved through the virtual functions of C + +.

Feel like you can use C + + in the future.

You are welcome to comment on the code https://github.com/clpsz/GOF-Design-Patterns and welcome the discussion.

 

23 C + + implementations of design patterns

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.