#include <iostream>
template<class Model, class View>
class Controller
{ /* Implement Controller */
};
template<class Model, class Controller>
class View
{ /* Implement View */
};
class Model
{ /* Implement Model */
};
////////////////////////////////////////////////////////////////////////////////
template<typename M>
class MyView;
template<typename M>
class MyController;
template<typename M>
class MyView : public View<M, MyController<M>>
{
public:
MyView(M* m) : m_model(m)
{
}
void setController(MyController<M>* controller)
{
m_controller = controller;
}
M* m_model;
MyController<M>* m_controller;
};
template<typename M>
class MyController : public Controller<M, MyView<M>>
{
public:
MyController(M* m) : m_model(m)
{
}
void setView(MyView<M>* view)
{
m_view = view;
}
M* m_model;
MyView<M>* m_view;
};
class MVC
{
Model m;
MyView<Model> v;
MyController<Model> c;
public:
MVC() : m(), v(&m), c(&m)
{
v.setController(&c);
c.setView(&v);
}
};
int main()
{
MVC mvc;
// TODO: use MVC here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKCnRlbXBsYXRlPGNsYXNzIE1vZGVsLCBjbGFzcyBWaWV3PgpjbGFzcyBDb250cm9sbGVyCnsgLyogSW1wbGVtZW50IENvbnRyb2xsZXIgKi8KfTsKCnRlbXBsYXRlPGNsYXNzIE1vZGVsLCBjbGFzcyBDb250cm9sbGVyPgpjbGFzcyBWaWV3CnsgLyogSW1wbGVtZW50IFZpZXcgKi8KfTsKCmNsYXNzIE1vZGVsCnsgLyogSW1wbGVtZW50IE1vZGVsICovCn07CgoKLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8KCnRlbXBsYXRlPHR5cGVuYW1lIE0+CmNsYXNzIE15VmlldzsKCnRlbXBsYXRlPHR5cGVuYW1lIE0+CmNsYXNzIE15Q29udHJvbGxlcjsKCnRlbXBsYXRlPHR5cGVuYW1lIE0+CmNsYXNzIE15VmlldyA6IHB1YmxpYyBWaWV3PE0sIE15Q29udHJvbGxlcjxNPj4KewpwdWJ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