// File: cctest8.cpp // // Use the ColorCube class. // Checking out function overloading vs inheritance. #include #include "ColorCube.h" using namespace std ; void foo1(ColorCube& cc1, ColorCube& cc2) { cout << "Called: foo1(ColorCube& cc1, ColorCube& cc2)\n" ; cc1.identify() ; cc2.identify() ; return ; } void foo1(ColorCube& cc, Box& b) { cout << "Called: foo1(ColorCube& cc, Box& b)\n" ; cc.identify() ; b.identify() ; return ; } void foo2(ColorCube& cc, Cube& c) { cout << "Called: foo2(ColorCube& cc, Cube& c)\n" ; cc.identify() ; c.identify() ; return ; } void foo2(ColorCube& cc, Box& b) { cout << "Called: foo2(ColorCube& cc, Box& b)\n" ; cc.identify() ; b.identify() ; return ; } int main() { ColorCube cc1(1.2, ColorCube::blue) ; // use alternate constructor ColorCube cc2(3.14, ColorCube::red) ; // use alternate constructor cout << "foo1: \n " ; foo1(cc1,cc2) ; cout <<"\n\n" ; cout << "foo2: \n " ; foo2(cc1,cc2) ; }