fork download
  1. #include <iostream>
  2.  
  3.  
  4. template<class Model, class View>
  5. class Controller
  6. { /* Implement Controller */
  7. };
  8.  
  9. template<class Model, class Controller>
  10. class View
  11. { /* Implement View */
  12. };
  13.  
  14. class Model
  15. { /* Implement Model */
  16. };
  17.  
  18.  
  19. ////////////////////////////////////////////////////////////////////////////////
  20.  
  21. template<typename M>
  22. class MyView;
  23.  
  24. template<typename M>
  25. class MyController;
  26.  
  27. template<typename M>
  28. class MyView : public View<M, MyController<M>>
  29. {
  30. public:
  31. MyView(M* m) : m_model(m)
  32. {
  33. }
  34.  
  35. void setController(MyController<M>* controller)
  36. {
  37. m_controller = controller;
  38. }
  39.  
  40. M* m_model;
  41. MyController<M>* m_controller;
  42. };
  43.  
  44. template<typename M>
  45. class MyController : public Controller<M, MyView<M>>
  46. {
  47. public:
  48. MyController(M* m) : m_model(m)
  49. {
  50. }
  51.  
  52. void setView(MyView<M>* view)
  53. {
  54. m_view = view;
  55. }
  56.  
  57. M* m_model;
  58. MyView<M>* m_view;
  59. };
  60.  
  61.  
  62. class MVC
  63. {
  64. Model m;
  65. MyView<Model> v;
  66. MyController<Model> c;
  67.  
  68. public:
  69. MVC() : m(), v(&m), c(&m)
  70. {
  71. v.setController(&c);
  72. c.setView(&v);
  73. }
  74. };
  75.  
  76. int main()
  77. {
  78. MVC mvc;
  79.  
  80. // TODO: use MVC here
  81.  
  82. return 0;
  83. }
Success #stdin #stdout 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty