David K in San Jose wrote:
Quote:
Problem fixed! I refused to give up, read some online C++/CLI
tutorials (!), and figured out what I was doing wrong. I was
incorrectly instantiating the delegate array elements by not using
the gcnew keyword.
For any other C++/CLI (i.e. "managed C++") newbies out there, here's
the way I got the array of delegates initialized properly:
>
In my original attempt, I was using this to instantiate the elements
in my array of delegates:
static array<TestFuncDelegate ^^TestFuncArray = gcnew
array<TestFuncDelegate ^{ TestFunc1,
TestFunc2,
TestFunc3
};
>
But I should have had this:
>
static array<TestFuncDelegate ^^TestFuncArray = gcnew
array<TestFuncDelegate ^{ gcnew TestFuncDelegate(TestFunc1),
gcnew TestFuncDelegate(TestFunc2),
gcnew TestFuncDelegate(TestFunc3)
};
>
>
...So now the error messages I was getting made perfect sense, but I
was too green to understand how to fix the problem until I studied up
on managed arrays<and delegates. :-)
Yup. There's no implicit conversion from the name of a function to a
delegate type in C++ (there is in C# though), so you have to explicitly
write each constructor call.
Quote:
>
Thanks to any of those who started to look into this for me.
>
David K in San Jose