共用方式為


weak_ptr::element_type

項目的型別。

typedef Ty element_type;

備註

這個型別是樣板參數的 Ty一個同義資料表。

範例

 

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

需求

標題: <memory>

命名空間: std

請參閱

參考

weak_ptr Class