C ++ documentation and the "Pod type" in the Microsoft. NET Framework ".

Source: Internet
Author: User
You can think of the pod type as a data type packaged with a green protective layer from outer space. The pod means "plain old data, that's "Full old data !) This is the meaning of the pod type. Its exact definition is quite rough (see the C ++ ISO standard). It basically means that the pod type contains raw data compatible with C. For example, the structure and integer types are pod type, but the classes with constructors or virtual functions are not. The pod type does not have virtual functions, base classes, user-defined constructor, copy constructor, value assignment operator, or destructor.
To conceptual the pod types, you can copy them by copying their bits. In addition, the pod type can be non-initialized. For example:
 
Struct rect R; // value undefinedpoint * Ppoints = new point [100]; // dittocstring s; // callctor ==> not pod

Initialization is usually required for non-pod types, whether it is to call the default constructor (provided by the compiler) or self-written constructor.
in the past, pods were important for developers who wrote compilers or C ++ Programs compatible with C. Now, the pod comes to the. NET environment. In managed C ++, managed types (including _ value and _ GC) can contain embedded native pod types. Figure 3 illustrates Code . Managed circle classes can contain point but cannot contain cpoint classes. If you try to compile pod. CPP will report a c3633 error: "cannot define ''m _ center'' as a member of managed ''circle'' because of the presence of default constructor ''cpoint :: cpoint ''on class ''cpoint ''. "(TRANSLATOR: Because the class cpoint has the default constructor 'cpoint: cpoint', you cannot define'm _ Center' as a member of the Managed class 'circle)
. net limits that embedded local objects can only be of the pod type. The reason is that they can be copied securely without worrying about calling constructors and initializing virtual tables, or any other mechanism not required by the pod type.

Related Article

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.