gpt4 book ai didi

visual-c++ - Windows Phone 8 RunTimeComponent 中的错误 “signature of public member contains native type”

转载 作者:行者123 更新时间:2023-12-04 04:30:59 24 4
gpt4 key购买 nike

我正在尝试创建一个支持 Windows Phone 8 的运行时组件。该计划的简要说明如下:

  1. 应用程序 (C#) 将在 ref struct A 中填充一些数据
  2. 它将使用 ref struct A 的对象调用 ref class VVoiP 的 init API。
  3. Ref 类 VVoip 需要有一个 B 类对象数组,以便它可以有多个实例。

C#代码:

using TestWRC;
namespace TestPrj
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
VVoIP v1 = new VVoIP();
A a1 = new A();
a1.a = 10;
v1.init(a1);
}
}
}

C++ 代码:

    namespace TestWRC
{
public ref struct A sealed
{
public:
property int a;
};

struct B {
A^ A_obj;
};

public ref class VVoIP sealed
{
private:
B array[3]; /* Array of object to have multiple instance */

public:
void init(A a1);
};
}


using namespace TestWRC;
void VVoIP::init(A a1)
{
array[0].A_obj->a = a1.a; /* Filling local array with initialized data*/
}

以上代码出现以下错误:

error C3992: 'init':signature of public member contains invalid type 'TestWRC::A'

我是 Windows Phone 8 的新手,请问有人告诉我这个错误是什么,以及如何纠正这个错误。提前致谢。

最佳答案

您的公共(public)签名需要指定这是一个 Windows 运行时引用计数对象,因此您需要使用帽子 (^) 语法进行声明。

void init(A^ a1);

关于visual-c++ - Windows Phone 8 RunTimeComponent 中的错误 “signature of public member contains native type”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15129507/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com