Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

#include <iostream>

using namespace std;


class first
{
public:
first()
{
cout<<"Constructor"<<endl;
}
~first()
{
cout<<"Destructor"<<endl;
}
};
class sec:public first
{
public:
sec()
{
cout<<"Constructor2"<<endl;
}
~sec()
{
cout<<"Destructor2"<<endl;
}
};
int main()
{
sec f;

return 0;
}
===================================================================================
========

#include <iostream>

using namespace std;


class first
{
public:
first()
{
cout<<"Constructor"<<endl;
}
~first()
{
cout<<"Destructor"<<endl;
}
};
class sec:public first
{
public:
sec()
{
cout<<"Constructor2"<<endl;
}
~sec()
{
cout<<"Destructor2"<<endl;
}
};
class third : public sec
{
public:
third()
{
cout<<"Constructor3"<<endl;
}
~third()
{
cout<<"Destructor3"<<endl;
}
};
int main()
{
third f;

return 0;
}
===================================================================================
==========

#include <iostream>

using namespace std;


class first
{
public:
first()
{
cout<<"Constructor1"<<endl;
}
~first()
{
cout<<"Destructor1"<<endl;
}
};
class sec:public first
{
public:
sec()
{
cout<<"Constructor2"<<endl;
}
~sec()
{
cout<<"Destructor2"<<endl;
}
};
class third : public first
{
public:
third()
{
cout<<"Constructor3"<<endl;
}
~third()
{
cout<<"Destructor3"<<endl;
}
};
int main()
{
third f;
sec s;
return 0;
}
===================================================================================
=======

#include <iostream>

using namespace std;


class first
{
public:
first()
{
cout<<"Constructor1"<<endl;
}
~first()
{
cout<<"Destructor1"<<endl;
}
};
class sec
{
public:
sec()
{
cout<<"Constructor2"<<endl;
}
~sec()
{
cout<<"Destructor2"<<endl;
}
};
class third : public first,public sec
{
public:
third()
{
cout<<"Constructor3"<<endl;
}
~third()
{
cout<<"Destructor3"<<endl;
}
};
int main()
{
third f;

return 0;
}
===================================================================================
========

#include <iostream>

using namespace std;


class first
{
public:
first()
{
cout<<"Constructor1"<<endl;
}
~first()
{
cout<<"Destructor1"<<endl;
}
};
class sec
{
public:
sec()
{
cout<<"Constructor2"<<endl;
}
~sec()
{
cout<<"Destructor2"<<endl;
}
};
class third : public sec,public first
{
public:
third()
{
cout<<"Constructor3"<<endl;
}
~third()
{
cout<<"Destructor3"<<endl;
}
};
int main()
{
third f;

return 0;
}

===================================================================================
========

#include <iostream>

using namespace std;


class first
{
public:
first()
{
cout<<"Constructor1"<<endl;
}
~first()
{
cout<<"Destructor1"<<endl;
}
};
class sec
{
public:
sec()
{
cout<<"Constructor2"<<endl;
}
~sec()
{
cout<<"Destructor2"<<endl;
}
};
class third : public sec,public first
{
public:
third()
{
cout<<"Constructor3"<<endl;
}
~third()
{
cout<<"Destructor3"<<endl;
}
};
class fourth : public third
{
public:
fourth()
{
cout<<"Constructor4"<<endl;
}
~fourth()
{
cout<<"Destructor4"<<endl;
}
};
class fifth: public third
{
public:
fifth()
{
cout<<"Constructor5"<<endl;
}
~fifth()
{
cout<<"Destructor5"<<endl;
}
};
int main()
{
//fifth f;
//fourth f;
third f;
return 0;
}

===================================================================================
========

You might also like