#include "stdafx.h"
#include <iostream>
using namespace std;
class Furniture
{
int weight;
public:
Furniture()
{
cout << "Furniture create" << endl;
}
~Furniture()
{
cout << "Furniture delete" << endl;
}
void set_weight(int w)
{
weight = w;
cout << "Furniture set_weight" <<endl;
}
int get_weight()
{
cout << "Furniture get_weight" <<endl;
return weight;
}
};
class Bed:public Furniture
{
public:
Bed()
{
cout << "Bed create" << endl;
}
~Bed()
{
cout << "Bed delete" << endl;
}
void sleep()
{
cout << "Bed sleep" <<endl;
}
};
class Sofa:public Furniture
{
public:
Sofa()
{
cout << "Sofa create" << endl;
}
~Sofa()
{
cout << "Sofa delete" << endl;
}
void watch_TV()
{
cout << "Sofa watch_TV" <<endl;
}
};
class Sleep_Sofa:public Bed,public Sofa
{
public:
Sleep_Sofa()
{
cout << "Sleep_Sofa create" << endl;
}
~Sleep_Sofa()
{
cout << "Sleep_Sofa delete" << endl;
}
void fold_out()
{
cout << "Sleep_Sofa fold_out" <<endl;
}
};
int main()
{
Sleep_Sofa sf;
sf.Sofa::set_weight(100);
cout << sf.Sofa::get_weight() << endl;
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
class Furniture
{
int weight;
public:
Furniture()
{
cout << "Furniture create" << endl;
}
~Furniture()
{
cout << "Furniture delete" << endl;
}
void set_weight(int w)
{
weight = w;
cout << "Furniture set_weight" <<endl;
}
int get_weight()
{
cout << "Furniture get_weight" <<endl;
return weight;
}
};
class Bed:public Furniture
{
public:
Bed()
{
cout << "Bed create" << endl;
}
~Bed()
{
cout << "Bed delete" << endl;
}
void sleep()
{
cout << "Bed sleep" <<endl;
}
};
class Sofa:public Furniture
{
int weight;
public:
Sofa()
{
cout << "Sofa create" << endl;
}
~Sofa()
{
cout << "Sofa delete" << endl;
}
void watch_TV()
{
cout << "Sofa watch_TV" <<endl;
}
void set_weight(int w)
{
weight = w;
cout << "Sofa set_weight" <<endl;
}
int get_weight()
{
cout << "Sofa get_weight" <<endl;
return weight;
}
};
class Sleep_Sofa:public Bed,public Sofa
{
public:
Sleep_Sofa()
{
cout << "Sleep_Sofa create" << endl;
}
~Sleep_Sofa()
{
cout << "Sleep_Sofa delete" << endl;
}
void fold_out()
{
cout << "Sleep_Sofa fold_out" <<endl;
}
};
int main()
{
Sleep_Sofa sf;
sf.Sofa::set_weight(100);
cout << sf.Sofa::get_weight() << endl;
Furniture fn;
fn.set_weight(1);
cout << fn.get_weight() << endl;
return 0;
}