Mail Archives: djgpp/1996/12/12/13:10:30
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 -