www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/13/02:53:28

From: urquhart AT netcomuk DOT co DOT uk (Adrian Urquhart)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help !
Date: Thu, 12 Dec 1996 18:56:15 GMT
Organization: NETCOM Internet Ltd.
Lines: 33
Message-ID: <32b054cc.28464557@nntp.netcruiser>
References: <32AF8925 DOT 7F68 AT snet DOT net>
NNTP-Posting-Host: dialup-12-25.netcomuk.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jean-Gaël GRICOURT <jean-gael DOT gricourt AT snet DOT net> wrote:

>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.
>
>
>#include <iostream.h>
>#include <stdlib.h>
>
>// Compile with DJGPP -> 
>
>class Myclass {
>
> int **mem; 
> int i,j;    
>
> public:
>        Myclass(int=0,int=0);    
>        ~Myclass();
>};
>
>Myclass::Myclass(int i0,int j0)
>{
> int x;
>
> i=i0;j=j0;
>
> *mem=new int[i];if(*mem==NULL) { cout<<"no memory\n";exit(1); }
Shouldn't this be: mem = new int * [i] ; //etc

Adrian.

- Raw text -


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