And then there is the speed issue
surface += CubeSurface(b);
elseif (b->type == CYLINDER)
surface += CylinderSurface(b);
elseif (b->type == SPHERE)
surface += SphereSurface(b);
elseif (b->type == PYRAMID)
surface += PyramidSurface(b);
surface += ConeSurface(b);
elseif (b->type == TORUS)
surface += TorusSurface(b);
elseif (b->type == TETRAHEDRON)
surface += TetrahedronSurface(b);
elseif (b->type == OCTAHEDRON)
surface += OctahedronSurface(b);
elseif (b->type == DODECAHEDRON)
surface += DodecahedronSurface(b);
elseif (b->type == ICOSAHEDRON)
surface += IcosahedronSurface(b);
elseif (b->type == ELLIPSOID)
surface += EllipsoidSurface(b);
elseif (b->type == PARABOLOID)
surface += ParaboloidSurface(b);
elseif (b->type == TTETRAHEDRON)
surface += TTetrahedronSurface(b);
elseif (b->type == TOCTAHEDRON)
surface += TOctahedronSurface(b);
elseif (b->type == TDODECAHEDRON)
surface += TDodecahedronSurface(b);
elseif (b->type == TICOSAHEDRON)
surface += TIcosahedronSurface(b);
elseif (b->type == TELLIPSOID)
surface += TEllipsoidSurface(b);
elseif (b->type == PARABOLOID)
surface += ParaboloidSurface(b);
So for each volume calculation there is a lot of decision-making until we have the proper routine. Compare that to our simple recipe with pointers to a function.
With objects, most of the decisions about functions are made at the time the object is constructed.