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.