假设我们有一秒钟
#include <boost/shared_ptr.hpp>
#include <iostream>
int main()
{
boost::shared_ptr<int> bleah(); //default constructor
cout << bleah.get() << endl; //error line
boost::shared_ptr<int> barf(new int (10));
cout << *barf.get() << endl; //outputs 10 as normal.
}
Run Code Online (Sandbox Code Playgroud)
怎么不编译?就好像函数shared_ptr :: get一下子从变量"bleah"的类定义中突然消失了.我确定这是有原因的,但我现在看不到它.