The following code results in C3867 (...function call missing argument list...) and C3350 (...a delegate constructor expects 2 argument(s)...). What am I doing wrong?
public ref class Form1 : public System::Windows::Forms::Form
{
public:
bool IsEven(int i){
return (i % 2) == 0;
}
Form1(void)
{
numbers = gcnew array<int>{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
};
array<int> ^even = Array::FindAll(
numbers, gcnew Predicate<int>(IsEven));
}
};
In C++/CLI you have to pass the actual instance of the type containing the function:
array<int> ^even = Array::FindAll(
numbers, gcnew Predicate<int>(this, &Test::IsEven));
(or make your IsEven
method static
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With