Exercise: Use Dynamic Traits

Let's go through what you’ve learned in this chapter.

We'll cover the following

This challenge is all about using dynamic traits to make objects give different results with the same trait.

Problem statement

You have a Cat and a Dog type, each implementing the Animal trait. Create a vector of pets, containing one cat and one dog. Iterate the vector and call the make_noise function on each pet.

Coding challenge

We encourage you to try solving it yourself before looking at the solution. Get started with the following code:

Get hands-on with 1400+ tech skills courses.