This question already has an answer here:
- Idiomatic way to prevent slicing? 3 answers
If I have eg:
class Base {};
class Derived : public Base {};
And a function:
Derived create_derived();
I'd like this to be ill-formed:
Base base = create_derived();
How can I do this?
Aucun commentaire:
Enregistrer un commentaire