标签:return rod factory virt 模式 creat odm int class
class IProduct
{
public:
virtual void prodMethod() = 0;
};
class Product: public IProduct
{
virtual void prodMethod()
{
cout<<"produmethod"<<endl;
}
};
class IFactory
{
public:
virtual IProduct * CreateProduct() = 0;
};
class Factory: public IFactory
{
public:
virtual IProduct * CreateProduct()
{
return new Product();
}
};
int main()
{
IFactory * pFac = new Factory();
IProduct * pPro = pFac->CreateProduct();
pPro->prodMethod();
return 0;
}
标签:return rod factory virt 模式 creat odm int class
原文地址:http://www.cnblogs.com/taotaoju/p/6003375.html