I am reading into Managed C++, came across this code
Code:
#using <mscorlib.dll>
using namespace System;
int main()
{
double salary = 12.84;
Console::Write("Salary: ");
Console::WriteLine(__box(salary));
Console::WriteLine();
return 0;
}
It was said that Write and WriteLine that we have used so far expect a specific type of value. To convert a regular type to this type of value, Managed C++ provides a unary operator called __box. This operator uses parentheses in which you type the value that needs to be converted.
So I tried this
Code:
#using <mscorlib.dll>
using namespace System;
int main()
{
double salary = 12.84;
Console::Write("Salary: ");
Console::WriteLine(salary);
Console::WriteLine();
return 0;
}
This also works fine....then why do I need to use __box.