title: Declaring an array of objects of a class when a (non) default constructor is (not) defined?
body: <p>Suppose I define a class in C++, MyClass, and want to create an array of 100 such objects, i.e. ArrayMyClass.</p>
  
  <p>Before that, lets say I declare a single object of MyClass, i.e.</p>
  
  <p>MyClass Obj;</p>
  
  <p>Lets take the following cases:</p>
  
  <ol>
  <li>MyClass has only a default constructor</li>
  <li>MyClass has only a non-default constructor with no default parameters</li>
  <li>MyClass has only a non-default constructor with default parameters</li>
  <li>MyClass has both a default and non-default constructor, but the latter has no default parameters</li>
  <li>MyClass has both a default and non-default constructor, but the latter has default parameters</li>
  <li>MyClass has 2 non-default constructors, one of them has default and the other has no default parameters</li>
  <li>MyClass has a default constructor, and two non-default constructors, one with default parameters and the other one doesn't have default parameters.</li>
  <li>MyClass has no constructors defined.</li>
  </ol>
  
  <p>I'm trying to figure out in which cases will the object get declared and which constructor gets invoked.</p>
  
  <p>My understanding is that the type of parameters passed on the object decides which constructor gets invoked. So,</p>
  
  <ol>
  <li>In case 1, object should get declared if no parameters are passed. If parameters are passed it should throw an error.</li>
  <li>In case 2, object should get declared only if I pass the right type of parameters. It should throw an error if I don't pass any parameters or if I pass the wrong type/number of parameters.</li>
  <li>Object should get declared, if I pass the right type/number of parameters, but also if I pass no parameters. It'll throw an error only if the type/number of parameters is incorrect.</li>
  <li>If no parameters are passed, the default constructor gets invoked. If the right parameters are passed the non default constructor gets invoked.</li>
  <li>In the case when I pass the right parameters, the non default constructor gets invoked. I'm confused what happens when you pass no parameters.</li>
  <li>In this case, if I pass no parameters, the non default constructor with default parameters should get invoked. I'm not sure what happens when you pass parameters. Is it that a class cannot have 2 constructors with the same type/number of parameters?</li>
  <li>This case looks similar to case 5 and I have the same confusion.</li>
  <li>In this case, if no parameters are passed, I assume C++ provides a built in bare bones constructor. But if I pass parameters it should throw an error.</li>
  </ol>
  
  <p>Suppose I declare an array of such objects, i.e.</p>
  
  <p>MyClass ArrayMyClass[100];</p>
  
  <p>For this declaration, from my understanding I've the same inferences for those 8 cases that I have with declaring just one object.</p>
  
  <p>Is my understanding is incorrect anywhere? Also what happens in those cases which I couldn't figure out?</p>