Near the beginning of the quarter we learned how to create our own data types with structs.

But what if we wanted to create “related” structs. For example, say we make a struct that represents computers. Well all computers have certain things in common like “CPU”, “RAM”, “power draw”, etc. But there are also radically different types of computers: like laptop and desktop. Laptops have special fields that only apply to them like “battery life” and “display size”. How can we represent that sort of relationship in our structs?

We use the idea of subtyping!

Oh, speaking of exclamation points…we know we can update primitive variable types. What about updating existing structs? Is that a thing we can do? (Yes. Time for some mutation! X-Men…assemble!)


Today's Resources

1. Exercise Files

Download Exercise Files

2. Slides

3. Pre-Recorded Lecture Video(s), Mini-Quizzes, and Live Recordings

Available Videos
Link Title Type Duration
Video 0 Live Lecture Recording lecture 50:00