Visual C++ .NET/Data Type/Cast
Convert Data with C-Style Casts
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
int intVal = 999688599;
double doubleVal = 54.8674;
int main(void)
{
Console::Write("doubleVal = ");
Console::WriteLine(doubleVal);
Console::Write("Result = ");
Console::WriteLine((int)doubleVal);
Console::Write("intVal = ");
Console::WriteLine(intVal);
Console::Write("Result = ");
Console::WriteLine((short)intVal);
return 0;
}
Remove the Const Attribute with a Cast
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
class MyClass
{
private:
int t;
public:
MyClass(int num) { t=num; }
int get() const { return t; }
void myFunc(){};
};
void main(void)
{
const MyClass a(10);
Console::WriteLine(a.get());
}