I want to create a new inherited class givin its base. For example:
class Base {
public:
void operator =(const Base &base) {
// copy base items
}
};
class Inherits: public Base {
public:
void operator =(const Inherits &inherits) {
// copy items
}
}
class InheritsAgain: public Base {
public:
void operator =(const InheritsAgain &ia) {
// copy items
}
}
int main(void) {
Inherits inherits;
InheritsAgain ia;
Add(inherits);
Add(ia);
}
Base &CreateNewItem(const &Base base) {
Base *lpbase;
lpbase = new Base;
*lpbase = const_cast<Base &>(base); // Copy new item
return lpbase;
}
I need to fire the Inherits copy function but it keeps wanting to fire
the Base copy function. Is there a better way to do this? I would
prefer the CreateNewItem function to handle the 'new' and 'delete'
operations of these new items. I need a generic function to do this
for all types of classes made from Base.