Cant copy construction be done without creating an explicit function in the pure virtual base class?
问题 My objective is to do a deep copy of a class, but a virtual class is causing trouble. #include<iostream> using namespace std; class Vir//pure virtual class { public: virtual void hi()=0; }; class Handler:public Vir { public: int i; Handler() {} Handler(int val):i(val) {} void hi() {cout<<"Value of i="<<i<<endl;} int getI() const {return i;} void setI(int j) {i=j;} }; class ControlPanel { public: Vir *v; ControlPanel(const ControlPanel& c)//copy constructor { v=new Handler; v->setI(c.getI());