EDIT: SOLVED
I\'m working on a multi-threaded project right now where I have a base worker class, with varying worker classes that inherit from it. At r
The problem appears to be that Director::manageWorker
is called in the constructor of workerVariant
instances:
Director::manageWorker(baseWorkerClass* worker) {
workerPtrArray[worker->getThreadID()] = worker;
}
Presumably getThreadID()
isn't a pure virtual function or you would have (hopefully!) gotten a compiler error about not overriding it in workerVariant
. But getThreadID()
might call other functions which you should override, but are being invoked in the abstract class. You should double check the definition of getThreadID()
to make sure you're not doing anything untoward that would depend on the child class before it's properly initialized.
A better solution might be to separate this sort of multi-stage initialization into a separate method, or to design Director
and baseWorkerClass
such that they don't have this sort of initialization-time interdependency.