我尝试从第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();
}
};