I thought I could do the following:
#include <iostream>
using namespace std;
class cl
{
public:
double* Arr;
cl(int);
};
cl::cl(int i)
{
Arr=new double[i];
Arr[0]=11;
};
int main()
{
cl* BB;
BB=new cl(3)[3]; /* I want to initialize a class member Arr for each element of the class cl array BB when I initialize this array by means of constructor. What should I do? */
cout << cl[1].Arr[0] << endl;
return 0;
}
but obviously something is wrong with the line where I noted. The compiler wouldn't compile.