// to compile this file, first save it as CalliTest.cpp, then type the following, // cl /clr CalliTest.cpp // an executable, CalliTest.exe, will be produced. This file is a mixed image that contains both managed and unmanaged code #include #using // Allow easy reference System namespace classes using namespace System; __gc class Simple { public: const static int i = 100; static Simple *s = new Simple(); }; int (*test)(int); int MyTest(int num) { printf("The argument is %d\n", num); return 1; } void funcPointerAsParam(int (*funcPtr)(int), int arg) { funcPtr(arg); } // Global function "main" is application's entry point void main() { // Write text to the console Console::WriteLine(L"Hello World using Managed Extensions!"); Simple* s = new Simple(); Console::WriteLine(s->i); Console::WriteLine("Hello World using Managed Extensions!"); test = MyTest; int ret = test(100); int (*funcPtr)(int); // function pointer as a local variable funcPtr = MyTest; ret = funcPtr(1000); funcPointerAsParam(MyTest, 10000); }