Last reading note of Deep Exploration C ++ Object Model

Source: Internet
Author: User
The last note of the book "Deep Exploration C ++ object model.

Chapter 2 describes the semantics of the execution period, mainly about how arrays are built and analyzed.

Chapter 2 describes the content of the template.

These two chapters are scattered in some books, such as Objective C ++, more objective C ++, C ++ primer, and C ++ templates Chinese edition, if you are interested, read the corresponding books.

This reading note mainly talks about your understanding of the meaning.

In my opinion, C ++ programming can be simply divided into three layers: the syntax layer and the language semantic layer (just like the semantics of the Deep Exploration C ++ object model) program semantics layer.

The syntax layer is easy to understand and learn. There are a lot of books explaining C ++ syntax. You can learn it if you want to learn more. However, reaching this level is only a very low level. For example, if I want to save five integers, I can write int N1, N2, N3, N4, N5;, but if so, it is very likely that the processing will be very troublesome in the future; although the above statements fully comply with the c ++ syntax requirements.

In fact, it is not easy to grasp the C ++ syntax well. You need to read books and practice them in depth. Even a good grasp of the majority of C ++ syntax is just the first step of the long journey.

What is higher than syntax is the language semantic layer. The language semantic layer is a ranking created by myself. What is the language semantic layer? A good explanation is that the written statement conforms to the syntax according to the specific implementation of the language. If C ++ primer is a good book about C ++ syntax, deep exploration of C ++ object model is a good book about C ++ language. Language semantics can be simply understood as the true semantics of the statements we write.

For example, you can write

 class Test
{
public:
    Test(wstring) : m_strName()//A
    {
          m_strName = _T(“”);   //B
    }

private:
    Wstring m_strName;
}

At this time, there are two methods for initializing m_strname: Method A or method B. Although both method A and method B comply with the syntax requirements, what is the more semantic requirement? Of course it is the statement (For details, refer to the book "Deep Exploration of C ++ Object Model"). Therefore, we should use the statement according to the meaning.

The language semantics layer mentioned in this Article refers to the content, that is, the meaning of the C ++ language. More efforts and practices are required to reach this level than to reach the above levels. Although this level is not more difficult to reach than the previous level, it is still easy to reach this level, as long as you work hard.

We can understand program semantics in this way: After complying with the syntax and language semantic layer requirements, we have now implemented a function, however, whether the methods we adopt can be modified, understandable, time efficiency, spatial efficiency, and so on. If language semantics is understood from the perspective of a statement or a single class, it means to understand whether the program we write is elegant and elegant from the perspective of the entire program; whether it can make people feel achievements and satisfaction. That is to say, we have adopted a good solution to solve this problem.

If you want to reach this level, you need to make unremitting efforts and good understanding. For example, if you want to sort a large array, the bubble method is generally not used for fast sorting. For example, you need an array that can save a certain type, but this type is not sure, the method for saving the void * pointer and forced type conversion is certainly better than the method similar to the vector in STL. The preceding two examples show the differences in semantics between different programs.

The mountains are far away and the road is under our feet. Wish we can reach the top of our dreams.

Series of articles:

Deep Exploration C ++ object model Reading Notes (1)

Deep Exploration C ++ object model Reading Notes (2)

Deep Exploration C ++ object model Reading Notes (3)

Deep Exploration C ++ object model Reading Notes (4)

Deep Exploration C ++ object model Reading Notes (5)

Deep Exploration C ++ object model Reading Notes (6)

Deep Exploration C ++ object model Reading Notes (7)

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.