3 ms·
Agreed. I'll add a note. There's still the slicing though.
by vickychijwani 12y ago
Agreed. I'll add a note. There's still the slicing though.
- nostrademons 12y agoFor slicing, the general rule in C++ is whenever you have a value object, polymorphism does not apply. A value object is always whatever its compile-time type is - after all, it's just a value, it can't represent some other "thing" that's off in some other memory space. Polymorphism only applies with pointers and references. Remember this rule and the throws behavior makes perfect sense, as do a lot of other C++ gotchas.