Abstract Factory(抽象工廠模式)


#include 
" AbstractProductB.h "
#include 
" AbstractProductA.h "
#include 
" AbstractFactory.h "

class  Client
{

public :
    Client();
    
virtual   ~ Client();
    AbstractProductB 
* m_AbstractProductB;
    AbstractProductA 
* m_AbstractProductA;
    AbstractFactory 
* m_AbstractFactory;

};
#include 
" Client.h "
Client::Client(){
}
Client::
~ Client(){
}
class  AbstractFactory
{
public :
    AbstractFactory();
    
virtual   ~ AbstractFactory();

    
virtual  CreateProductA();
    
virtual  CreateProductB();
};
AbstractFactory::AbstractFactory(){
}
AbstractFactory::
~ AbstractFactory(){
}
AbstractFactory::CreateProductA(){
}
AbstractFactory::CreateProductB(){
}
#include 
" AbstractFactory.h "
/* *
 * This class implements the operations to create concrete product objects.
 
*/
class  ConcreteFactory1 :  public  AbstractFactory
{

public :
    ConcreteFactory1();
    
virtual   ~ ConcreteFactory1();
    CreateProductA();
    CreateProductB();
};
#include 
" ConcreteFactory1.h "
ConcreteFactory1::ConcreteFactory1(){
}
ConcreteFactory1::
~ ConcreteFactory1(){
}
ConcreteFactory1::CreateProductA(){
}
ConcreteFactory1::CreateProductB(){
}
#include 
" AbstractFactory.h "

/* *
 * This class implements the operations to create concrete product objects.
 
*/
class  ConcreteFactory2 :  public  AbstractFactory
{

public :
    ConcreteFactory2();
    
virtual   ~ ConcreteFactory2();

    CreateProductA();
    CreateProductB();

};
#include 
" ConcreteFactory2.h "


ConcreteFactory2::ConcreteFactory2(){

}



ConcreteFactory2::
~ ConcreteFactory2(){

}





ConcreteFactory2::CreateProductA(){

}


ConcreteFactory2::CreateProductB(){

}
class  AbstractProductA
{

public :
    AbstractProductA();
    
virtual   ~ AbstractProductA();

};
#include 
" AbstractProductA.h "


AbstractProductA::AbstractProductA(){

}



AbstractProductA::
~ AbstractProductA(){

}
class  AbstractProductB
{

public :
    AbstractProductB();
    
virtual   ~ AbstractProductB();

};
#include 
" AbstractProductB.h "


AbstractProductB::AbstractProductB(){

}



AbstractProductB::
~ AbstractProductB(){

}

#include 
" AbstractProductA.h "

/* *
 * This class (a) defines a product object to be created by the corresponding
 * concrete factory, and (b) implements the AbstractProduct interface.
 
*/
class  ProductA1 :  public  AbstractProductA
{

public :
    ProductA1();
    
virtual   ~ ProductA1();

};
#include 
" ProductA1.h "


ProductA1::ProductA1(){

}



ProductA1::
~ ProductA1(){

}

转载于:https://www.cnblogs.com/jerry550409/archive/2009/02/18/1393379.html

你可能感兴趣的:(Abstract Factory(抽象工廠模式))