When is default constructor generated in C++
<p>As per "Inside C++ Object Model" a copy constructor is generated (if not declared by the programmer) by the compiler only when at least any one of the below four conditions are true:</p>

<ol>
<li><p>When the class contains a member object of a class for which a copy constructor exists (either explicitly declared by the class designer, as in the case of the previous String class, or synthesized by the compiler, as in the case of class Word)</p></li>
<li><p>When the class is derived from a base class for which a copy constructor exists (again, either explicitly declared or synthesized)</p></li>
<li><p>When the class declares one or more virtual functions</p></li>
<li><p>When the class is derived from an inheritance chain in which one or more base classes are virtual</p></li>
</ol>

<p>Which means if I have a class with just constructor then copy constructor will not be provided by the compiler.</p>

<p>Lets take an example:</p>

<pre><code>class test
{
    test(){}
};
int main()
{
    test obj1;       //statement 1
    test obj2(obj1); //statement 2
}
</code></pre>

<p>Above code works fine. Now the problem comes when I add the following lines in class test:</p>

<pre><code>test(const test&amp; rhs) = delete;
</code></pre>

<p>"= delete" ensures that copy constructor is not automatically provided. After adding above line I am getting an error for statement 2 which says <code>Use of deleted function test::test(const test&amp;)</code>.</p>

<p>My question is: as per "Inside C++ Object Model" I don't need a copy constructor for the above class so when I am explicitly saying not to generate a copy constructor (using delete) why am I getting an error? Since I was expecting that the compiler won't need a copy constructor for the above class.</p>

<p>I am using gcc version 4.6.3.</p>
