Is it a way to make that deleted method(e.g. copy operations) also won't be possible to define in the derived classes? As if I will access with the base class pointer how it supposed to work?
class A
{
public:
A() = default;
~A() = default;
A(const A& a) = delete;
A& operator=(const A& a) = delete;
};
class B : public A
{
int n{1};
public:
//why am I allowed do that? it's deleted in the base class
B(const B& b) { n = b.n; }
B& operator=(const B& b) { n = b.n; }
};
Aucun commentaire:
Enregistrer un commentaire