C ++ class usage notes

Source: Internet
Author: User

C ++ class usage notes
When we create A class, we sometimes want to initialize the class members to 0; for example, class A; we define A m_a; sometimes we will simply use memmset (& m_a, 0, sizeof (A); in this way, it seems that the m_a member is cleared by 0. In fact, this usage is incorrect. In fact, when we create A class object, the class object has a function table. If 0 is cleared, all these tables will be invalid. In this case, the program's memory access error is often returned. So we can go to Struct to clear 0, but be careful with any memory operations of the class.

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.