class Pelicula
{
private:
int cantActores=10;
Actor listaActores[cantActores];
public:
void setlistaActores(int f){cantActores=f;};
int getlistActores(){return cantActores;};
}
It does keeps me saying invalid non static member
class Pelicula
{
private:
int cantActores=10;
Actor listaActores[cantActores];
public:
void setlistaActores(int f){cantActores=f;};
int getlistActores(){return cantActores;};
}
It does keeps me saying invalid non static member
You may not use a non-static non-constant data member as a size of a data member of an array type.
Moreover variable length arrays is not a standard C++ feature.
What you need is to declare a template class like for example
template <size_t cantActores>
class Pelicula
{
private:
Actor listaActores[cantActores];
public:
size_t getlistActores() const {return cantActores;};
};
So if you need objects of the class that would contain arrays of different sizes then just specify the size as template argument.
Another approach is to use the standard class template std::vector
instead of the array.