zoukankan      html  css  js  c++  java
  • 设计模式原型模式实现C++

    /*********************************
    *设计模式--原型模式实现
    *C++语言
    *Author:WangYong
    *Blog:http://www.cnblogs.com/newwy
    ********************************/
    #include <iostream>
    using namespace std;
    class Prototype
    {
    	public:
    	virtual ~Prototype(){};
    	virtual Prototype *Clone() const = 0;	
    };
    Prototype *Prototype::Clone()const{return 0;}
    class ConcretePrototype:public Prototype
    {
    	public:
    	ConcretePrototype(){};
    	~ConcretePrototype(){};
    	ConcretePrototype(const ConcretePrototype &cp)
    	{
    		cout<<"ConcretePrototype copy..."<<endl;
    	}
    	Prototype* Clone()const
    	{
    		return new ConcretePrototype(*this);	
    	}
    };
    int main()
    {
    	Prototype *p = new ConcretePrototype();
    	Prototype *p1 = p->Clone();
    	return 0;
    }
    
    
  • 相关阅读:
    CF1515G
    杂题
    ARC120E
    CF1528F
    ICPC2021银川C
    gym102129F
    杂记6.15
    杂记5.12
    杂记4.1
    杂记3.17
  • 原文地址:https://www.cnblogs.com/newwy/p/1855227.html
Copyright © 2011-2022 走看看