13.22
#include <string>class Hasptr {public: HasPtr(const std::string &s = std::string()) : ps(new std::string(s)), i(0) { } HasPtr(const HasPtr& hp) : ps(new std::string(*hp.ps)), i(hp.i) { } HasPtr& Operator=(const HasPtr& rhs){ if(this=&rhs) return this; delete ps; ps=new string (*rhs.ps); i=rhs.i; return *this; } ~HasPtr(){ delete ps; }PRivate: std::string *ps; int i;};新闻热点
疑难解答