#include <iostream>
using namespace std;
//
struct IOS
{
public:
virtual ~IOS() { }
virtual void InstallOS_Imp() = 0;
};
class CWindowsOS : public IOS
{
public:
virtual ~CWindowsOS() { }
virtual void InstallOS_Imp() { cout<<"Windows."<<endl; }
};
class CLinuxOS : public IOS
{
public:
virtual ~CLinuxOS() { }
virtual void InstallOS_Imp() { cout<<"Linux."<<endl; }
};
class CUnixOS : public IOS
{
public:
virtual ~CUnixOS() { }
virtual void InstallOS_Imp() { cout<<"Unix."<<endl; }
};
//
struct IComputer
{
public:
virtual ~IComputer() { }
virtual void InstallOS(IOS *pOS) = 0;
};
class CHPComputer : public IComputer
{
public:
virtual ~CHPComputer() { }
virtual void InstallOS(IOS *pOS)
{
cout<<"HP ";
pOS->InstallOS_Imp();
}
};
class CAppleComputer : public IComputer
{
public:
virtual ~CAppleComputer() { }
virtual void InstallOS(IOS *pOS)
{
cout<<"Apple ";
pOS->InstallOS_Imp();
}
};
class CDellCompute : public IComputer
{
public:
virtual ~CDellCompute() { }
virtual void InstallOS(IOS *pOS)
{
cout<<"Dell ";
pOS->InstallOS_Imp();
}
};
//
void main()
{
IOS *pOS = new CLinuxOS;
CDellCompute Computer;
Computer.InstallOS(pOS);
delete pOS;
}