将RAII class对象转换为其所含原始资源,有两个做法:显示转换和隐式转换 显示: std::trl::shared_ptr<Investment>pInv(createInvestment()); int daysHeld(const Investment* pi); int days = daysHeld(pInv);//错误 int days = daysHeld(pInv.get());//正确 隐式: class Investment{ public: bool isTaxFree() const; ... }; Investment* createInvestment(); std::trl::shared_ptr<Investment> pil(creatInvestment()); bool taxable1 = !(pil->isTaxFreeee());//经由operator->访问资源 ... std::auto_ptr<Investment> pi2(createInvestment()); bool taxable2 = !((*pi2).isTaxFree()); ... 一般而言显式转换比较安全,但隐式转换对客户比较方便