다음을 통해 공유


shared_ptr::operator->

지정 된 값에 대한 포인터를 가져옵니다.

Ty *operator->() const;

설명

The selection operator returns get(), so that the expression sp->member behaves the same as (sp.get())->member where sp is an object of class shared_ptr<Ty>. Hence, the stored pointer must not be null, and Ty must be a class, structure, or union type with a member member.

예제

 

// std_tr1__memory__shared_ptr_operator_ar.cpp 
// compile with: /EHsc 
#include <memory> 
#include <iostream> 
 
typedef std::pair<int, int> Mypair; 
int main() 
    { 
    std::shared_ptr<Mypair> sp0(new Mypair(1, 2)); 
 
    std::cout << "sp0->first == " << sp0->first << std::endl; 
    std::cout << "sp0->second == " << sp0->second << std::endl; 
 
    return (0); 
    } 
 
  

요구 사항

헤더 <memory>

네임스페이스: std

참고 항목

참조

shared_ptr 클래스

shared_ptr::get

shared_ptr::operator*