I would like to know, if I have a class with an array attribute whose size is not the same for all instances :

```
class myObject{

private:
    int size;
    int* array;

// other methods/attributes

};

```

Is it obligatory allocated using new ?

```
explicit myObject(int size = 0):size(size){
    array = new int[size];
}

```

Even if in the main(), I always use constant parameters to create the instances of the class ? (Meaning I know every array size at compile time).

```
int main{
    myObject object (5);
    return 0;
}

```

Apparently something like :

```
private:
    int size;
    int array[size];

```

wont work, no ?

That means that array attribute whose size are not constant of the class are obligatory on the heap ?

Thank you for your answers,