www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/12/15:11:32

Date: Fri, 13 Dec 1996 09:06:21 +0000
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: Help !
To: jean-gael DOT gricourt AT snet DOT net
Cc: djgpp AT delorie DOT com
Reply-to: billc AT blackmagic DOT tait DOT co DOT nz
Message-id: <32B11C8D.50EF@blackmagic.tait.co.nz>
Organization: Tait Electronics NZ
MIME-version: 1.0
References: <32AF8925 DOT 7F68 AT snet DOT net>

Jean-Ga=EBl GRICOURT wrote:
>=20
> I can't figure out what's wrong with this, I got an error
> (General protection fault) when I ran it.
> I used DJGPP V2.
>=20

[snip]

>         Myclass(int=3D0,int=3D0);
>         ~Myclass();
> };
>=20
> Myclass::Myclass(int i0,int j0)
> {
>  int x;
>=20
>  i=3Di0;j=3Dj0;
>=20
>  *mem=3Dnew int[i];if(*mem=3D=3DNULL) { cout<<"no memory\n";exit(1)=
; }
>  for(x=3D0;x<i;x++)
>  {
>   mem[x]=3Dnew int[j];
>   if(mem[x]=3D=3DNULL) { cout<<"no memory\n";exit(1); }
>  }
> }

Malloc (and thus new) will not allocate 0 bytes, and will return a nu=
ll
pointer.

Bill
--=20
Leave others their otherness.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019