Creating a struct containing "derived variables"

(Or define any function that returns your struct, for that matter. A constructor is just a conveniently named function for a “standard” way to form your struct, especially if you need to enforce some requirement that must be true of your struct fields, but if there are multiple different ways you might want produce your struct then you might want multiple different function names.)

4 Likes