Mail Archives: djgpp/1994/01/15/22:15:21
Dear Mathew:
The problem is strcpy() in the Command class creator. It needs
a place to copy name to. Here is a working example of your code:
/////////////////////////////////////
#include <stdio.h>
#include <string.h>
typedef int classes; // Whatever classes are.
class Command {
classes _cl;
char _name[80]; // The string goes here.
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() { }
};
int main(int argv, char* argc[]) {
classes temp_cl; // dummy classes.
printf("About to create C_create:\n");
C_create *temp = new C_create(temp_cl, argc[1]); // A pointer
C_create temp2(temp_cl, argc[1]); // or a local var
printf("Created C_create successfully!\n");
}
/////////////////////////////////////////////////
No, there is not a new bug for the new function.
-- Greg
- Raw text -