作者:悦爱张晓桀 | 来源:互联网 | 2023-09-07 20:47
最近4G很火的样子,谈论GSM似乎已经过时了,不过我还是觉得弄懂GSM之后,再去弄CDMA以及LTE都要方便的很多,现在我们来用最通俗的话来说一下第二代通信系统的基本原理,其实《大
Prototype模式通过复制原型(Prototype)而获得新对象创建的功能,这里Prototype本身就是“对象工厂”
prototype.h:
#ifndef _PROTOTYPE_H_
#define _PROTOTYPE_H_
class Prototype
{
public:
virtual ~Prototype();
virtual Prototype* Clone() cOnst= 0;
protected:
Prototype();
private:
};
class ConcretePrototype:public Prototype
{
public:
ConcretePrototype();
ConcretePrototype(const ConcretePrototype& cp);
~ConcretePrototype();
Prototype* Clone() const;
protected:
private:
};
#endif //~_PROTOTYPE_H_prototype.cpp:
#include "prototype.h"
#include
using namespace std;
Prototype::Prototype(){
}
Prototype::~Prototype(){
}
Prototype* Prototype::Clone() const{
return 0;
}
ConcretePrototype::ConcretePrototype(){
}
ConcretePrototype::~ConcretePrototype(){
}
ConcretePrototype::ConcretePrototype(const ConcretePrototype& cp){
cout<<"ConcretePrototype copy ..."<}
Prototype* ConcretePrototype::Clone() const{
return new ConcretePrototype(*this);
}main.cpp:
#include "prototype.h"
#include
using namespace std;
int main(){
Prototype* p = new ConcretePrototype();
Prototype* p1 = p->Clone();
return 1;
}
大白话说GSM系统,布布扣,bubuko.com