📄 valueclasses.cpp
字号:
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
#include <tchar.h>
using namespace System;
__value class SmallData {
public:
int weight;
int GetData() { return weight * 100; }
};
__value struct QuickInfo {
int height;
int width;
};
struct QuickInfo2 {
int height;
int width;
};
void Process(Object *obj) {
Console::WriteLine(obj->GetType());
}
// This is the entry point for this application
int _tmain(void)
{
SmallData x;
QuickInfo a;
a.height = 10;
QuickInfo2 b;
b.height = 20;
x.weight = 10;
__box SmallData *px = __box(x);
Process(px);
px->weight++;
x= *px;
Console::WriteLine(x.weight);
// Generic type for boxed value
Object *px2 = __box(x);
__try_cast<SmallData *>(px2)->weight++;
x = *__try_cast<SmallData *>(px2);
Console::WriteLine(x.weight);
// TODO: Please replace the sample code below with your own.
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -