1

这些天,我正在使用 MS Visual Studio 2010 Professional 处理 C++/CLI (Visual C++) 项目。我有一个SRecognizer使用一些 C# 库的类。现在,它有以下代码

r = gcnew RTMotionDetector();

Thread ^detectionThread = gcnew Thread(gcnew System::Threading::ThreadStart(this,&r->start()));

该类RMotionDetector的标题如下

#pragma once
#include "MotionDetector.h"

ref class RTMotionDetector :
    public MotionDetector
{
public:
    RTMotionDetector(void);
    ~RTMotionDetector(void);
    void start();
    void pause();
    void stop();

private:
    VideoCapture *cam1;
};

当程序运行时,它给出了以下错误

1>------ Build started: Project: Automated Intruder Tracking System, Configuration: Debug Win32 ------
1>Build started 7/3/2013 1:03:49 PM.
1>InitializeBuildStatus:
1>  Touching "Debug\Automated Intruder Tracking System.unsuccessfulbuild".
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>ClCompile:
1>  All outputs are up-to-date.
1>  SRecognizer.cpp
1>SRecognizer.cpp(38): error C2102: '&' requires l-value
1>SRecognizer.cpp(38): error C3350: 'System::Threading::ThreadStart' : a delegate constructor expects 2 argument(s)
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.19
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

如您所见,错误在于我如何创建SRecognizer您已经拥有上述特定代码的线程。我对 C++/CLI 相当陌生。

4

1 回答 1

1

这应该修复编译器错误:

Thread^ detectionThread = gcnew Thread(gcnew System::Threading::ThreadStart(r, &RTMotionDetector::start));
于 2013-07-03T07:37:36.037 回答