作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是问题所在:
namespace Program1 {
public ref class Form1 : public System::Windows::Forms::Form
{
public: Form1(void) {....}
private: RunnableThread^ peerThread;
private: System::Void loginButton_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
String^ ip = this->ipTextField->Text;
String^ port = this->portTextField->Text;
<.............>
// Start new thread
this->peerThread = gcnew RunnableThread("thread2", ip, port, this->gameMatrix, this);
<..............>
}
}
}
// Runnable class
ref class RunnableThread
{
private:
String^ ip;
String^ port;
<...>
EchoClient3WS::Form1^ refToRootObj;
<......>
public:
RunnableThread(String^ threadName, String^ ip, String^ port, GameMatrix^ gameMatrix, Program1::Form1^ rootObj);
void run();
void callServer(String^ message);
void done();
};
'private: RunnableThread^ peerThread;'
error C2146: syntax error : missing ';' before identifier 'peerThread' k:\visual studio 2010\projects\program1\program1\Form1.h <....>
namespace Program1 { public ref class Form: <...> {
// HERE WE DON'T KNOW ANYTHING ABOUT THE CLASS NAMED 'RunnableThread'
} }
最佳答案
在 class Form1
前添加前向声明:
class RunnableThread;
ref
在前。
关于visual-c++ - 两个类对象之间的 Visual C++/CLI 相互访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3941255/
我是一名优秀的程序员,十分优秀!