Learn diary interpreter mode and effective C + +

Source: Internet
Author: User

interpreter mode (interpreter): Given a language, defines a representation of its grammar and defines an interpreter that uses that representation to interpret sentences in the language.


(1) If a particular type of problem occurs at a sufficiently high frequency, it may be worthwhile to describe each instance of the problem as a simple language sentence. This allows you to construct an interpreter that solves the problem by interpreting these sentences.

(2) When a language needs to be interpreted and executed, and you can represent a sentence in that language as an abstract syntax tree, you can use the interpreter pattern.

(3), it is easy to change and expand the grammar, because the pattern uses classes to represent grammar rules, and you can use inheritance to change and extend the grammar. It is also easier to implement grammars, because the class implementations that define the various nodes in the abstract syntax tree are broadly similar and are easy to write directly.

(4), the interpreter pattern defines at least one class for each rule in the grammar, so a grammar that contains many rules can be difficult to manage and maintain. It is recommended to use other techniques such as the parser and compiler builder to handle grammar when it is very complex.


Customizing New and delete:


1: Understanding the behavior of New-handler

(1), Set_new_handler allows a client to specify a function that is called when memory allocation is not met.

(2), nothrow New is a fairly limited tool because it only applies to memory allocations, and subsequent constructors may throw exceptions.

2: Understand the appropriate replacement time for new and delete

(1) There are many reasons to write a custom new and delete, including improving performance, debugging the heap using errors, and collecting heap usage information.


Today's summary:

(1), recognizing the meaning of native window. Detailed reference: http://blog.csdn.net/dbzhang800/article/details/7006270

(2), Nativeevent want to capture events in the top-level form and need to install filters


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.