I'm totally new to cpp but know some python. I want to create a class which has an array as an attribute with size given in the constructor. Here is what I want to do but in python:
class test:
def __init__(self,size):
self.arr = [x for x in range(size)]
This is what I have in c++:
class Field{
public:
int width;
int height;
int field[];
Field(int _width, int _height){
width = _width;
height = _height;
field = new int[width*height];
}
};
But when declaring the field I need to provide a size, but the size is only given later. How can I do this?