How can I define an array as a member of class while its size determined somewhere else and actually it is passed to the constructor.
More detail:
There is an array of integer numbers and is defined a public member in class.
class foo {
public:
int *arr[];
int s;
};
However the size of array is passed in the constructor.
foo::foo()
: s (array_size)
{
}
What is the correct syntax of doing such thing?
The correct way of doing this is to use the STL and
std::vector< int >for such tasks. The following is a rough outline that may work for you:Further information on vectors can be found here. Further suggestions:
_).