Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Type-cast operator between auto_gcroot and compatible types.
template<typename _other_type>
operator auto_gcroot<_other_type>();
Return Value
The current auto_gcroot cast to auto_gcroot<_other_type>.
Example
// msl_auto_gcroot_op_auto_gcroot.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 );
}
};
ref class ClassB : ClassA {
public:
ClassB( String ^ s) : ClassA( s ) {}
virtual void PrintHello() new {
Console::WriteLine( "Hello from {0} B!", m_s );
}
};
int main() {
auto_gcroot<ClassB^> b = gcnew ClassB("first");
b->PrintHello();
auto_gcroot<ClassA^> a = (auto_gcroot<ClassA^>)b;
a->PrintHello();
}
Hello from first B!
Hello from first A!
Requirements
Header file <msclr\auto_gcroot.h>
Namespace msclr