3 ms·
You have a shape which can be either a circle which then has a radius, or a rectangle which has width/height. The shape cannot be anything else, this is importa
by aldanor 4y ago
You have a shape which can be either a circle which then has a radius, or a rectangle which has width/height. The shape cannot be anything else, this is important and something you want to rely on and express in code. In C++ you can't easily do this on the language level. In Rust (albeit in a somewhat limited way) and functional languages, you can, via enums where variants can host other types.