auto_handle::operator auto_handle
Type-cast operator between auto_handle and compatible types.
template<typename _other_type>
operator auto_handle<_other_type>();
Return Value
The current auto_handle cast to auto_handle<_other_type>.
Example
// msl_auto_handle_op_auto_handle.cpp
// compile with: /clr
#include <msclr\auto_handle.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_handle<ClassB> b = gcnew ClassB("first");
b->PrintHello();
auto_handle<ClassA> a = (auto_handle<ClassA>)b;
a->PrintHello();
}
Hello from first B! Hello from first A!
Requirements
Header file <msclr\auto_handle.h>
Namespace msclr