我经常声明类包装单个Plain Old Data值;简单的类没有虚拟功能,如:C++:POD和POD包装对象
class Velocity {
int vel;
public:
// functions to work with velocity ...
}
与这样的对象的工作是相同的与POD的值工作? - 如果在我的代码中使用了
int
而不是Velocity
,那么空间或时间使用情况是否有所不同?标准是否对此有所说明?我可以将指针或这样的对象的阵列作为POD值,反之亦然的指针/数组? - 我完全安全吗
Velocity *v = reinterpret_cast< Velocity* >(int_pointer)
?