# \[C++\] Dynamic object creation with array and non-default constructor

**URL:** <https://forum.kirupa.com/t/c-dynamic-object-creation-with-array-and-non-default-constructor/211324>\
**Category:** programming\
**Created:** [December 29, 2006, 10:44pm UTC](https://forum.kirupa.com/t/c-dynamic-object-creation-with-array-and-non-default-constructor/211324 "2006-12-29T22:44:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MTsoul](https://avatars.discourse-cdn.com/v4/letter/m/91b2a8/32.png) [@MTsoul](https://forum.kirupa.com/u/MTsoul)\
**Post date:** [December 29, 2006, 10:44pm UTC](https://forum.kirupa.com/t/c-dynamic-object-creation-with-array-and-non-default-constructor/211324/1 "2006-12-29T22:44:40Z")

</div>

Suppose I want to dynamically create a non-fixed number of a certain class of objects at runtime.

```auto
int i;
cin >> i;
MyClass * my_objects;
my_objects = new MyClass(<some parameter>)*;

```

This syntax is obviously wrong, according to my compiler. But you probably know what I’m trying to do. I want to create an array of _i_ MyClass’es, each calling a constructor that has some parameter.

my\_objects = new MyClass \*; works, but I want to call a constructor other than the default constructor for each new object. How do I do this?
