I am writing a program with C++ and since it is going to be big and a lot of people will edit this, I am going to use the MVC pattern. The question is very easy.

There is a controller that is the intermediate between the model (.cpp and .h files) and the view (made with Qt). Since the controller is only one and it has to manage everything during the lifetime of the app, do I have to deny copy constructor and copy assignment like this?

class Controller {
  Controller(const Controller& x) = deltete;
  Controller& operator=(const Controller& x) = delete;

Is this still flexible? Because I don't see the sense of having 3 instances of a controller and each of them manage a different part of the program. There must be only one, am I correct?


closed as off-topic by Toby Speight, Ludisposed, t3chb0t, pacmaninbw, Mast Dec 8 '17 at 15:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Looks like a syntax error to me - unless your implementation has a macro called deltete. \$\endgroup\$ – Toby Speight Dec 8 '17 at 9:32

It sounds like what you want is a hard-enforced singleton.

With an interface like the following, you can provide a hard guarantee that only a single instance of Controller will ever exist:

class Controller {
  static Controller& instance();


I am personally partial to Meyer's singleton for the implementation:

// in .cpp file:

Controller& Controller::instance() {
  static Controller the_instance;
  return the_instance;

Not the answer you're looking for? Browse other questions tagged or ask your own question.