I am planning on porting some Python code to C++. I want to use C++11 techniques.
I have defined this class:
class Scenario
{
public:
Scenario();
~Scenario();
private:
std::shared_ptr<Scheduler> scheduler;
};
With empty constructor and destructor. This compiles.
However when changing shared_ptr to unique_ptr, compilation fails with a message that the default constructor is deleted and not accessible.
Question 1: Why?
The following:
class Scenario
{
public:
Scenario();
private:
std::unique_ptr<Scheduler> scheduler;
};
does compile however.
Question 2: Why does defining a destructor causes the constructor to be deleted.
Aucun commentaire:
Enregistrer un commentaire