克隆成语中使用默认复制构造函数是否存在问题?

时间:2017-05-27 15:46:39

标签: c++ c++11

我有:

class myClass : public baseClass
{
public:

myClass(const unsigned short int    dim_alphabet ,const string *alf ,const map<vector<string>, int> &samples );
myClass(const approximateOracle& apOracle); //copy constructor
virtual ~myClass();
virtual myClass* clone() const;
virtual bool    myMethod(vector<SYMBOL> str);
virtual bool    myMethod2(dfa* dfahp , vector<SYMBOL>* witness_results=NULL);




private:

void encode_data(vector< pair<vector<double> , labelType> > &mapped_samples , const map<vector<string>, int> &samples);
int length_longer_sentence;
vector<double> mean;
vector<double> standard_deviation; //data structure for save the standard_deviation of features

clone()的实现是:

myClass* myClass::clone() const
{
return(new myClass(*this)); //this code cause the call of copy constructor
}

我正在使用克隆成语。 我会删除复制构造函数的显式定义。我还没有需要深层复制的指针。因此,使用编译器提供的默认复制构造函数(如果我删除了我的),myClass成员的自动浅层副本应该没问题。

但我有一些疑问,因为克隆成语的存在。有关删除显式复制构造函数的禁忌症吗?

0 个答案:

没有答案