lundi 11 février 2019

Initializing abstract class with deleted copy constructor

I have an abstract class with deleted copy constructor and copy assignment operator that is meant to be used as a public interface:

struct connection {
    // Make object non copyable.
    connection(const connection &) = delete;
    auto operator=(const connection &) -> connection & = delete;
    // Make class abstract.
    virtual ~connection() = 0;
  };

I'm trying to create a class that inherits from it:

struct abstract_connection : connection {...};

but I get the following error in the constructor:

constructor for 'abstract_connection' must explicitly initialize the base class 'connection' which does not have a default constructor

Why does this happen when I delete the copy constructor and operator?

Aucun commentaire:

Enregistrer un commentaire