Mail Archives: djgpp/1994/01/15/20:16:04
I have the following class declarations (among others) for a set of execution
commands:
//////////////////////////////////////////////////
class Command
{
	classes		_cl;
	char*		_name;
protected:
	Command(classes cl,char* name)
	{
		_cl = cl;
		strcpy(_name,name);
	}
public:
	virtual int Perform() = 0;
	virtual char* isA() { return "Command"; }
};
class C_create:public Command
{
public:
	C_create(classes cl,char* name) : Command(cl,name) {}
	virtual char* isA() { return "C_create"; }
	virtual int Perform() {}
};
///////////////////////////////////////////////////
Now, later on I have the following code
	printf("About to create C_create:\n");
	temp = new C_create(cl,arg[1]);
	printf("Created C_create successfully!\n");
As far as I know, the syntax for the middle line is correct, and it compiles
without error. When I run the program however, the first printf() goes, and
then a segmentation fault occurs.
Can anyone see what is going on here? Is there a know "new" operator bug?
thanx in advance
+---------------------------+-------------------------------------------------+
| Matthew D Moss   :-p  ;-) | I tried to think of an extremely witty quote to |
| INTERNET: mmoss AT panix DOT com | put here. Unfortunately, there's no room left.  |
+---------------------------+-------------------------------------------------+
- Raw text -