TransformNode with 4 bytes to alignment boundary
这是导致此警告的代码:
class TransformNode : public Node {
public:
int number;
public:
void test() { number = 12; }
};
//Node.h
class Node {
public:
typedef std::set<Node *> ChildSet;
protected:
ChildSet mChildren;
Node * mParent;
public:
Node(Node * parent=0) : mParent(parent) {}
~Node() {}
Node * addChild(Node * node);
inline Node * getParent() { return mParent; }
const ChildSet &getChildren() const { return mChildren; }
};
inline void node_test() {
TransformNode * node = new TransformNode;
node->test();
std::cout << node->number << "\n";
}
int main() {
node_test();
return 0;
}
当我从类 TransformNode派生Node类时发生错误。我正在使用打开所有警告并将警告视为错误的 xcode 5.0。我真的很想了解这段代码发生了什么,所以仅仅关闭警告或停止将它们视为错误并不是我想要处理的方式。
编辑:添加了更多代码。澄清一些细节(粗体)
谢谢,
加西姆