How are objects created in C++?
<p>I know Java but don't have much knowledge of C++. I am trying to write a class for the first 3 statements in main function of the code at <a href="https://developers.google.com/v8/get_started" rel="nofollow">https://developers.google.com/v8/get_started</a>.</p>

<p>First I have questions about how objects are created in C++. See the below code.</p>

<pre><code>HandleScope handle_scope;
Persistent&lt;Context&gt; context = Context::New();
Context::Scope context_scope(context);
</code></pre>

<p>I think in C++ when you declare a variable of a class an instance of the class created at the point. You do not need to use new keyword like in Java. So the first statement would create an instance of HandleScope which will be stored in handle_scope. 
Now I do not understand how the second statement would work. With my knowledge the part before = will create a new Persistent object which can be referred by the variable context. Then Context::New() will create a new object and store it in context? Huh, I know I am wrong. But I simply dont get how it would work?</p>

<p>I am trying to write a C++ class for the above. Here is my attempt.</p>

<pre><code>class MyClass {
private:
    HandleScope handle_scope;
    Persistent&lt;Context&gt; context;
    Context::Scope context_scope;

public:
    MyClass(); 
};

MyClass::MyClass()
{
    context = Context::New();
    context_scope = new Context::Scope(context);
}
</code></pre>

<p>Have I done the initialization properly?</p>

<p>EDIT: Reply to peachykeen (in comments) 
I did the following experimentation.</p>

<p>I wrote a Test class as below.
 Test
    {
    public:
        Test() {
        cout &lt;&lt; "Test" &lt;&lt; endl;
    }
    };</p>

<p>In the main function I wrote Test test; It outputs "Test" which means an object is created without using new keyword.</p>
