delegate.cpp

来自「C++ Source code from a tutorial」· C++ 代码 · 共 29 行

CPP
29
字号
// 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;

__delegate int MyDelegate();

__gc class EventHandlers {
public:
    int test1() { return 100; }
    static int test2() { return 200; }
};

// This is the entry point for this application
int _tmain(void)
{
    // TODO: Please replace the sample code below with your own.
    EventHandlers *handler = new EventHandlers;

    MyDelegate *del = new MyDelegate(handler, EventHandlers::test1);
    Console::WriteLine(del->Invoke());
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?