www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/12/13:10:30

From: Jean-Gaël GRICOURT <jean-gael DOT gricourt AT snet DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Help !
Date: Wed, 11 Dec 1996 23:25:09 -0500
Organization: A customer of SNET Internet: http://www.snet.net/
Lines: 51
Message-ID: <32AF8925.7F68@snet.net>
Reply-To: jean-gael DOT gricourt AT snet DOT net
NNTP-Posting-Host: brpt01-sh3-port151.snet.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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); }
 for(x=0;x<i;x++)
 {
  mem[x]=new int[j];
  if(mem[x]==NULL) { cout<<"no memory\n";exit(1); }
 }
}

Myclass::~Myclass()
{ delete mem; }


void main()
{
 char    tab[50];
 int     i,j;
 Myclass obj1,obj2,obj3,obj4;

 i=100;j=100;

 obj1=Myclass(i,j);
}


mailto:

- Raw text -


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