2

I am working on a game, creating a basic, Model-View-Controller, setup. I am trying to create three variables, a Model, a View which takes a pointer to model and a controller which takes a pointer to Model and View. However I am getting an error saying that the constructor for Views(Model*) has been declared implicitly and cannot be referenced as it has been deleted. I have attempted many things but have yet to find a solution to this. Any help would be greatly appreciated! Below is all the code in question, I can include anything else that is requested!

     From Game.h:
    #include "Controller.h"
    #include "Model.h"
    #include "Views.h"

    class Game
    {
    public:
        Game();
        ~Game();

        int launch();

        Controller contrl;
        Model model;
        Views view;
    };



     From Game.cpp
        Game::Game()
        {
            model = Model();
            view = Views(&model); // <- gives error
            contrl = Controller(&model, &view);

        }

Views.h:
#include <SFML\Graphics.hpp>
#include "Model.h"

    class Views
    {

    public:
        Views();
        Views(Model*);
        ~Views();

        int render();

        sf::RenderWindow window;
        Model* model;

    };

    Views.cpp:
    Views::Views()
    {

    }

    Views::Views(Model* m) {
        model = m;
    }

    Views::~Views()
    {
    }
Ben Atkinson
  • 53
  • 1
  • 8
  • Off topic note: learn about base and member initializer syntax in constructors. You should be initializing member objects and base classes using that rather than assignment from temporary objects. – Kaz Feb 16 '16 at 21:36
  • Sorry I may be misunderstanding how Circular Dependencies work, but is that not when a class requires itself? – Ben Atkinson Feb 16 '16 at 21:37
  • I will certainly look into that! Thanks. – Ben Atkinson Feb 16 '16 at 21:38

0 Answers0