Mail Archives: djgpp/1996/12/12/15:11:32
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 -