当我打印下面定义的类的sizeof(SenseNode)时,返回4。由于2个uint8_t私有成员,我期望它为2。 我用其他2个字节做什么?
enum NodeType { unknown = 255, temperature=0, button=1, text=2, page=3, dualstate=4, slider=5, alarmHandler=6, clock=7, gps=8,
yawpitchroll = 9, gsm = 10, alert = 11 };
class SenseNode {
public:
SenseNode(uint8_t id) : SenseNode(id, NodeType::unknown) {};
SenseNode(uint8_t id, NodeType type) : id(id), nodeType(type) {};
virtual ~SenseNode() = default;
// Dispatcher of notifyObserver
virtual void notifyObserver2(SenseObserver* observer);
/* Accessor for property Id */
uint8_t getId() { return id; }
NodeType getNodeType() { return nodeType; }
private:
uint8_t id = 0;
uint8_t nodeType = NodeType::unknown;
};