ATL的offsetofclass中,为啥_ATL_PACKING是8的解释

ATL的offsetofclass中,为啥_ATL_PACKING是8的解释

解答出处

http://stackoverflow.com/questions/5014061/whats-the-use-of-atl-packing-constant-when-computing-distance-from-the-start-o

 

C++标准规定:

编译器的类的类型转换对空指针(NULL)特殊处理,即你NULL进行强制类型转化的结果还是NULL,所以….

				static_cast类型转化的时候,_ATL_PACKING的值得是非零就好
		
				
				 

C++ Standard 4.10/3 Pointer conversions [conv.ptr]:

An rvalue of type “pointer to cv D,” where D is a class type, can be converted to an rvalue of type “pointer to cv B,” where B is a base class (clause 10) of D. If B is an inaccessible (clause 11) or ambiguous (10.2) base class of D, a program that necessitates this conversion is ill-formed. The result of the conversion is a pointer to the base class sub-object of the derived class object. The null pointer value is converted to the null pointer value of the destination type.

你可能感兴趣的:(ATL的offsetofclass中,为啥_ATL_PACKING是8的解释)