我經常聲明類包裝單個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)
?