从嵌套类的类中获取对象并调用func()

时间:2019-05-06 09:11:39

标签: c++-cli inner-classes

我尝试从第3行获取Button对象,以用于更改按钮文本和调用函数func()进行线程化。似乎出现了错误。 嵌套类调用和获取对象的正确方法是什么?

public ref class Form1
{
    private: System::Windows::Forms::Button^  Button1;
    ref class A
    {
        void func()
        {
            Button1->Text = L"X";       //left of '->Text' must point to class/struct/union/generic type
        }
    };
    private: void Button1_Click(System::Object^  sender, System::EventArgs^  e)
    {
        A^ obj = gcnew func();           //syntax error : identifier 'func'
        Thread^ t = gcnew Thread(gcnew ThreadStart(obj, &Form1::A::func));     
        t->Start();
    }
};

0 个答案:

没有答案