#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
class BaseClass { virtual void F(){} };
class DerivedClass : public BaseClass {};
int main(void)
{
DerivedClass* a = new DerivedClass;
BaseClass* b = dynamic_cast<BaseClass*>(a);
if (b != 0)
Console::WriteLine("Conversion to base class successful.");
else
Console::WriteLine("Conversion to base class unsuccessful.");
delete a;
return 0;
}
|