#include <iostream>
#include <boost/shared_ptr.hpp>
using namespace std;
using boost::shared_ptr;
using boost::weak_ptr;
int main() {
shared_ptr<int> p(new int(5));
weak_ptr<int> q = p;
if(shared_ptr<int> r = q.lock())
{
cout << r << endl;
}
return 1;
}
大家好,当我编译上面的代码以熟悉boost :: weak_ptr时,我遇到了以下编译错误:variable ‘boost::weak_ptr<int> q’ has initializer but incomplete type
。任何人都可以帮我弄清楚哪里出错了?提前致谢!