我对C/C++很陌生,通常我用C#编写代码,所以我有一个问题:
enum PrimitiveType {
BOOL,
STRING,
INT8,
INT16,
INT32,
UINT8,
UINT16,
UINT32,
};
struct MyValue
{
public:
String Id
PrimitiveType ValueType;
[???] Value;
};
Run Code Online (Sandbox Code Playgroud)
我想将int
s,string
s和bool
s 存储在该"Value"
属性中.在C#,我将宣布Value
为对象和把对象到一个int
或bool
像:
if(myValueObject.ValueType == BOOL)
auto value = (bool)myValueObject.ValueType;
Run Code Online (Sandbox Code Playgroud)
我可以在C++中使用哪种类型?