Well I'm not sure that's exactly what I'm doing. I have a base class called Space and several derived classes, including PassiveSpace. I want to take advantage of virtual functions so that if I have an array of spaces and call
Code:
theSpaces[ someNum ].action()
it calls the appropriate function. My problem is in actually creating the array to begin with. I have something like this:
Code:
Space * itsSpaces = new Space[ 40 ];
:
: // later
:
itsSpaces[0] = new PassiveSpace( /* appropriate constructor args go here */ );
itsSpaces[1] = new PassiveSpace( /* ditto */ );
:
: // etc
But I got an error regarding "no operator= defined for right-hand operand of type class Property *". So I went ahead and defined it:
Code:
PassiveSpace& Space::operator=( PassiveSpace * thePass ) {
delete this;
return *thePass;
}
Now it compiles OK, but I'm getting runtime assertion failures that I am pretty sure are a result of this operation. My question is - is that operator= legal? Or is there some better way to do it? Any help would be welcome....thanks in advance!