#include class Car { private: Car(){}; int _no; public: Car(int no) { _no=no; } void printNo() { std::cout<<_no<
You can create an array of pointers.
Car** mycars = new Car*[userInput]; for (int i=0; i
or
Car() constructor does not need to be public. Add a static method to your class that builds an array:
static Car* makeArray(int length){ return new Car[length]; }