基类定义如下:
class Query{
public:
virtual Query *clone() = 0;
};
派生类定义如下:
class NameQuery : public Query
{
public:
virtual Query *clone()
{
return new NameQuery(*this);
}
};
Query *pq = new NameQuery();
Query *pq1 = pq->clone();//获取抽象基类的“拷贝”
转载于:https://www.cnblogs.com/handongdong/archive/2011/10/25/2223764.html