3 ms·
If you try to use inheritance, object slicing by far. I understand the practical reasons for it, but it feels very wrong.
by rileymat2 5y ago
If you try to use inheritance, object slicing by far.
I understand the practical reasons for it, but it feels very wrong.
- ncmncm 5y agoIt only ever comes up in toy examples. Working programmers do not encounter it, so in practice it is never the cause of a problem.
- TinkersW 5y agoSlicing requires you to treat a reference type as a value type, nobody who knows C++ does this, so slicing is pretty much restricted to people coming in from Java land or similar. I've not encountered a single instance of slicing in 10+ years of C++.