domingo, 22 de febrero de 2015

Herencia Multiple Visual C++



#include <iostream>
#include <cstdlib>

using namespace std;

class Bed
{
public:

 Bed() {}
 void sleep()
 {
  cout << "Dormir" << endl;
 }

 int weight;
};

class Sofa
{
public:

 Sofa() {}
 void watchTV()
 {
  cout << "Miro Tele" << endl;
 }
};

class SleeperSofa : public Bed , public Sofa //la herencia multiple
{
public:

 SleeperSofa() {}
 void foldOut()
 {
  cout << "Plegable" << endl;
 }
};

int main( int argc , char *argv[] )
{
 SleeperSofa ss;

 ss.watchTV();

 ss.foldOut();

 ss.sleep();

 system("pause");
 return 0;
}

No hay comentarios:

Publicar un comentario