Struct 错误C3767:Visual Studio 2010无法访问候选函数
我得到了这个错误:Struct 错误C3767:Visual Studio 2010无法访问候选函数,struct,c++-cli,Struct,C++ Cli,我得到了这个错误: error C3767: 'phys1::point::get_prev': candidate function(s) not accessible 这是我的密码 物理学 using namespace System; namespace phys1 { typedef struct position{ int x; int y; } pos; public ref class point{ public: point(fl
error C3767: 'phys1::point::get_prev': candidate function(s) not accessible
这是我的密码
物理学
using namespace System;
namespace phys1 {
typedef struct position{
int x;
int y;
} pos;
public ref class point{
public:
point(float speed, float gr);
public:
pos get_prev();
public:
pos get_next();
};
}
phys.cpp
// This is the main DLL file.
#include "phys.h"
using namespace System;
namespace phys1 {
...
static pos point::get_prev(){
pos point;
point.x=x;
point.y=y;
return point;
}
...
}
我试图在库中使用的结构是否有问题?我可以用另一种方式构建它吗?如果您试图跨程序集边界传递
pos
类型的值,则它应该是公共管理类型<代码>公共价值结构pos最适合您所做的事情
默认情况下,本机类型在程序集边界上是不可见的,使它们可见的
#pragma
与其说是真正的解决方案,不如说是一个混乱的问题。只需使用元数据创建一个适当的.NET类型。 < p>你是混合C++语法和C++/CLI语法。“结构”是一个本机定义(C++)之一。
要声明“struct”,最好使用“value-struct”结构
“不可访问”错误也可能是由于“位置”被隐式声明为“私有”
有关托管类型声明的更多信息,请参见此处:d
static
来自何方?它不在类内的声明中!