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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -