// AmbiguousInheritance - both Bed and Sofa can inherit from // a common class Furniture // This program does not compile! #include #include class Bed { public: Bed() { cout << "Building the bed part\n"; } void sleep() { cout << "Trying to get some sleep over here!\n"; } int weight; }; class Sofa { public: Sofa() { cout << "Building the sofa part\n"; } void watchTV() { cout << "Watching TV\n"; } int weight; }; //SleeperSofa - is both a Bed and a Sofa class SleeperSofa : public Bed, public Sofa { public: // the constructor doesn't need to do anything SleeperSofa() { cout << "Putting the two together\n"; } void foldOut() { cout << "Folding the bed out\n"; } }; int main() { // output the weight of the sleepersofa SleeperSofa ss; cout << "sofa weight = " << ss.weight //this doesn't work! // << ss.Sofa::weight // this does work << "\n"; return 0; }