📜  union cpp - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:56.274000             🧑  作者: Mango

代码示例1
union S
{
    std::string str;
    std::vector vec;
    ~S() {} // needs to know which member is active, only possible in union-like class 
};          // the whole union occupies max(sizeof(string), sizeof(vector))