I know the code is missing (Someone will give negative numbers). But I only want to know how do you solve constructor injection in this situation?
class PresenterFactory
{
public:
template<class TModel>
AbstractPresenter<TModel>*
GetFor(AbstractView<TModel> * view)
{
return new PresenterA(view, new FakeNavigator());
}
};
class ViewA : public AbstractView<ModelA>
{
static PresenterFactory factory;
public:
ViewA(AbstractPresenter<ModelA> *presenter = factory.GetFor<ModelA>(this)) :
AbstractView<ModelA> (presenter)
{
}
// this one is also not working
// invalid use of ‘class ViewA’
// ViewA()
// {
// this->ViewA(factory.GetFor<ModelA> (this));
// }
};