array of pointers and pointer to an array in c++

Viewed 157

i have a class in which it's protected section i need to declare an array with unknown size (the size is given to the constructor as a parameter), so i looked around and found out that the best possible solution is to declare an array of pointers, each element points to an integer:

int* some_array_;

and simply in the constructor i'll use the "new" operator:

some_array_ = new int[size];

and it worked, my question is: can i declare an array in a class without defining the size? and if yes how do i do it, if not then why does it work for pointers and not for a normal array?

EDIT: i know vecotrs will solve the problem but i can't use them on my HW

3 Answers
Related