Streaming Out Multiple Objects
But what happens when you stream out two objects, or three? What if we stream out cat followed by dog and then cat again?
dog* blue_dog = new dog("blue");
out << yellow_cat << blue_dog << yellow_cat;
Now you have three separate scopes reference resolution. If the same reference occurs in both contexts, as yellow_cat does here, it will be streamed out twice, once for each scope.