Here we have Cuboid and Sphere types, both of which have Volume and SurfaceArea methods. We also have a PrintInfo function that accepts a Cuboid, and calls Volume and SurfaceArea on it so it can print that info.
In the main function we pass a Cuboid to PrintInfo, which compiles fine. But then we try to pass a Sphere to PrintInfo as well, which results in a compile error. PrintInfo is only set up to accept Cuboid values, even though Sphere values have identical methods.
Let’s get the PrintInfo function to accept both Cuboid and Sphere values. Define a Solid interface consisting of Volume and SurfaceArea methods. Then modify PrintInfo to accept a parameter with a Solid interface type instead of Cuboid.