#include <iostream> using namespace std; class Base1 { private: int x; protected: int getx() { return x; } public: void setx(int a=1) {x=a;} }; class Base2 { private: int y; public: void sety(int a) {y=a;} int gety() {return y;} }; class Base3 { private: int z; public: void setz(int a) {z=a;} int getz() {return z;} }; class Derived:public Base1,public Base2,public Base3 { private: int d; public: void setd(int a) {d=a;} void display(); }; void Derived::display() { cout<<"Base1....x="<<getx()<<endl; cout<<"Base2....y="<<gety()<<endl; cout<<"Base3....z="<<getz()<<endl; cout<<"Derived..d="<<d<<endl; } void main() { Derived obj; obj.setx(1); obj.sety(2); obj.setz(3); obj.setd(4); obj.display(); }