Factory Method and Cyclic Dependancy
- by metdos
If I'm not wrong, because of its nature in factory method there is cyclic dependency:
Base class needs to know subclasses because it creates them, and subclasses need to know base class. Having cyclic dependency is bad programming practice, is not it?
Practically I implemented a factory, I have problem above, even I added
#ifndef MYCLASS_H
#define MYCLASS_H
#endif
I'm still getting
Compiler Error C2504 'class' : base class undefined
And this error disappers when I remove subclass include from base class header.