Share via


auto_gcroot::operator->

 

The latest version of this topic can be found at auto_gcroot::operator->.

The member access operator.

Syntax

_element_type operator->() const;  

Return Value

The object that is wrapped by auto_gcroot.

Example

// msl_auto_gcroot_op_arrow.cpp  
// compile with: /clr  
#include <msclr\auto_gcroot.h>  
  
using namespace System;  
using namespace msclr;  
  
ref class ClassA {  
protected:     
   String^ m_s;  
public:  
   ClassA( String^ s ) : m_s( s ) {}  
  
   virtual void PrintHello() {  
      Console::WriteLine( "Hello from {0} A!", m_s );  
   }  
  
   int m_i;  
};  
  
int main() {  
   auto_gcroot<ClassA^> a( gcnew ClassA( "first" ) );  
   a->PrintHello();  
  
   a->m_i = 5;  
   Console::WriteLine( "a->m_i = {0}", a->m_i );  
}  
Hello from first A!  
a->m_i = 5  

Requirements

Header file <msclr\auto_gcroot.h>

Namespace msclr

See Also

auto_gcroot Members
auto_gcroot::get