You must actually allocate an array; and you want to use a pointer type, float array[] not what you think there. Since juanchopanza reminds us, you also want to either turn off the copy constructor, or the assignment operator, or implement those that make the proper deep copy.
However, if you have some kind of dynamic automatic container (for example, std::vector ), you can use it instead - then you do not need to deal with copy / assignment / destructor / memory management.
source share