// SleeperSofa - demonstrate how a sleeper sofa might work #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() { SleeperSofa ss; //you can watch TV on a sleeper sofa... ss.watchTV(); //Sofa::watchTV() //...and then you can fold it out... ss.foldOut(); //SleeperSofa::foldOut() //...and sleep on it (sort of) ss.sleep(); //Bed::sleep() return 0; }