共用方式為


shared_ptr::operator*

取得指定的值。

Ty& operator*() const;

備註

間接取值運算子傳回 *get()。 因此,儲存的指標不可以是 null。

範例

 

// std_tr1__memory__shared_ptr_operator_st.cpp 
// compile with: /EHsc 
#include <memory> 
#include <iostream> 
 
int main() 
    { 
    std::shared_ptr<int> sp0(new int(5)); 
 
    std::cout << "*sp0 == " << *sp0 << std::endl; 
 
    return (0); 
    } 
 
  

需求

標題: <memory>

命名空間: std

請參閱

參考

shared_ptr Class

shared_ptr::get