Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Een interface kan een statische constructor hebben, die kan worden gebruikt om statische gegevensleden te initialiseren. Een statische constructor wordt maximaal één keer aangeroepen en wordt aangeroepen voordat een lid van de statische interface voor het eerst wordt geopend.
Voorbeeld
// mcppv2_interface_class2.cpp
// compile with: /clr
using namespace System;
interface struct MyInterface {
static int i;
static void Test() {
Console::WriteLine(i);
}
static MyInterface() {
Console::WriteLine("in MyInterface static constructor");
i = 99;
}
};
ref class MyClass : public MyInterface {};
int main() {
MyInterface::Test();
MyClass::MyInterface::Test();
MyInterface ^ mi = gcnew MyClass;
mi->Test();
}
in MyInterface static constructor
99
99
99