📄 managedclass.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;
__gc class Numbers {
public:
int x;
int y;
};
__abstract __gc class Car {
public:
int Year;
};
__gc class Porsche : public Car {
public:
int TopSpeed;
};
__sealed __gc class Final {
public:
int CantDerive;
};
__gc class Berzerkle {
public:
__property int get_Weight() { return weight; }
__property void set_Weight(int newvalue);
protected:
int weight;
};
void Berzerkle::set_Weight(int newvalue) {
if (newvalue >= 0) {
Console::WriteLine(
"Error: Weight must be negative.");
}
else {
weight = newvalue;
}
}
// This is the entry point for this application
int _tmain(void)
{
Numbers *num = new Numbers;
num->x = 10;
num->y = 20;
Console::WriteLine(num->x);
Porsche *car = new Porsche;
Berzerkle *MyBerz = new Berzerkle;
MyBerz->Weight = 500;
MyBerz->Weight = -10;
Console::WriteLine(MyBerz->Weight);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -