Mail Archives: djgpp/2000/07/26/16:45:14
On Fri, 21 Jul 2000 09:36:49 +0100, Anthony Appleyard
<Anthony DOT Appleyard AT umist DOT ac DOT uk> wrote:
> I wrote a Gnu C++ program with this text in;-
>
> class atom{public: double x,y,z; char mat,vis; atom(){};
> atom(xyz c,char m=0,char v=0){x=c.x; y=c.y; z=c.z; mat=m; vis=v;};
>
> atom((*C)[N+1][N+1])= /*HERE*/ malloc((N+1)*(N+1)*(N+1)*sizeof(atom));
>
> My Gnu C++ compiler accepts this, but moans that implicit conversion
> from void* to a pointer is non-ANSI, so I likely couldn't use that
> program text in my good old faithful Borland C++ 4.52 for Windows. To
> make this text ANSI, what should I insert at /*HERE*/ ?
Nothing. You should use 'new' instead of malloc.
atom (*C)[N+1][N+1] = new atom [N+1][N+1][N+1];
supposing that N is a macro or a const known at compile time.
Regards
Horst
- Raw text -