two way to initialize a structure : <p>What's the difference between the two ways of creating a structure?</p>

<p>No.1 is right, and No.2 gives the error: </p>

<pre><code>reference binding to misaligned address 0x63775f5f00676e6f for type 'const int', which requires 4 byte alignment
</code></pre>

<p>What's the difference between the two ways of creating a structure?</p>

<p>What did the No.2 do?</p>

<p>Here is my codes. </p>

<p>Thank you.</p>

<pre><code>/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    TreeNode* buildTree(vector&lt;int&gt;&amp; preorder, vector&lt;int&gt;&amp; inorder) {     
        if (preorder.size() == 0 || inorder.size() == 0)
            return nullptr;

        // # 1
        // struct TreeNode *RootTree = new TreeNode(preorder.front());

        // # 2
        struct TreeNode RootNode(preorder.front());
        struct TreeNode *RootTree = &amp;RootNode;

        return RootTree;
    }    
};
</code></pre>
