auto_gcroot::operator-> 

The member access operator.


_element_type operator->() const;

The object that is wrapped by auto_gcroot.

// 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 );
}

Output

Hello from first A!
a->m_i = 5

Header file <msclr\auto_gcroot.h>

Namespace msclr

Community Additions

ADD
Show: