c++ - How can I get the address of scoped_ptr? -
i'm studying smart pointers, in particular scoped_ptr
. read operators *
, ->
. tried run code:
int main(){ boost::scoped_ptr<int>number(new int); *number = 432; std::cout<<"value: "<<*number <<std::endl<< " adress: "<< number <<std::endl; return 0; }
and result is:
value: 432 adress: 1
that isn't correct.
how have use ->
operator correct address?
use get()
member function:
boost::scoped_ptr<int>number(new int); *number = 432; std::cout<<"value: "<<*number <<std::endl<< " adress: "<< number.get() <<std::endl;
more details here
Comments
Post a Comment