Why am I getting an ERROR?!?  
Author Message
vicarious





PostPosted: Visual C++ General, Why am I getting an ERROR?!? Top

I really can't see how this causes an error. This is the whole program:

int main()
{
double* pbeans;
pbeans = new double [3][4];

delete [] pbeans;

return 0;
}

when I try to compile this i get the error message:

(4) : error C2440: '=' : cannot convert from 'double (*)[4]' to 'double *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


How am I supposed to dynamically declare this array



Visual C++16  
 
 
Mike Danes





PostPosted: Visual C++ General, Why am I getting an ERROR?!? Top

The error message is quite explicit, pbeans must be of type double(*)[4]. That means you have to write it like this:

int main()
{
double (*pbeans)[4];

...




 
 
Sarath.





PostPosted: Visual C++ General, Why am I getting an ERROR?!? Top

You can define like

double** ppbeans;