15. 智能指针可以通过get操作
#include <iostream> #include <cstdlib> #include <memory> using namespace std; class Orange { private: int weight; public: Orange(int w) : weight(w) {} int getWeight() {return weight;} }; int main() { shared_ptr<Orange> p(new Orange(123)); Orange* ptr = p.get(); ptr++; ptr--; cout<<ptr->getWeight()<<endl; return 0; }
16. new[] 对应用delete[]
Effective C++ .15,16获取原始资源和成对使用同类型new和delete
原文:http://www.cnblogs.com/lailailai/p/4177122.html