#define win 0
#define mac 1
#include <iostream>
using namespace std;
class button
{
public:
button(){}
virtual ~button(){}
virtual void showbutton()=0;
};
class winbutton : public button
{
public:
winbutton(){}
virtual ~winbutton(){}
void showbutton(){cout<<"win button"<<endl;}
};
class macbutton : public button
{
public:
macbutton(){}
virtual ~macbutton(){}
void showbutton(){cout<<"mac button"<<endl;}
};
class factory
{
public:
factory(){}
virtual ~factory(){}
virtual button *createbutton()=0;
};
class winfactory : public factory
{
public:
winfactory(){}
virtual ~winfactory(){}
button *createbutton(){return new winbutton;}
};
class macfactory : public factory
{
public:
macfactory(){}
virtual ~macfactory(){}
button *createbutton(){return new macbutton;}
};
int main()
{
factory *fc=new winfactory;
button *bt=fc->createbutton();
bt->showbutton();
delete bt;
delete fc;
fc=new macfactory;
bt=fc->createbutton();
bt->showbutton();
delete bt;
delete fc;
system("pause");
return 0;
}