#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;
}
Hi all, when I compile above codes to be familiar with boost::weak_ptr, I encountered the following compiling error: variable ‘boost::weak_ptr<int> q’ has initializer but incomplete type
. Could anyone help me figure out where is wrong? Thanks in advance!