不同的数据单元(Node)使用同一种数据结构的实现,在程序中怎么处理最好?
解决方案
enum TypeId {String, Int, Bool, /* ... */ }struct Value { TypeId type; union { char* stringValue; int intValue; bool boolValue; /* ... */ }}
不同的数据单元(Node)使用同一种数据结构的实现,在程序中怎么处理最好?
enum TypeId {String, Int, Bool, /* ... */ }struct Value { TypeId type; union { char* stringValue; int intValue; bool boolValue; /* ... */ }}