CLI中报错无法访问私有成员,但是我的属性明明是public
求解,我写了个CLI项目程序,调用了c++代码,会报错无法访问私有成员,错误信息如下:
error C2248: “TopoShapeGroup::WireGroup”: 无法访问 private 成员(在“TopoShapeGroup”类中声明)
我的TopoShapeGroup.h头文件内容如下:
public ref class TopoShapeGroup
{
public:
BRepBuilderAPI_MakeWire *WireGroup;//BRepBuilderAPI_MakeWire是一个c++类,我把它作为类成员
public:
//拷贝构造函数
TopoShapeGroup(const TopoShapeGroup^ c)
{
WireGroup=c->WireGroup;
}
TopoShapeGroup^ TopoShapeGroup::operator=(const TopoShapeGroup ^RightSides)
{
this->WireGroup=RightSides->WireGroup;
return this;
}
TopoShapeGroup();
void Add(Circ^ c);
void Add(Lin^ l);
};
使用的过程如下:
void View(TopoShapeGroup^ profile,Lin^ path)
{
BRepBuilderAPI_MakeWire *WireGroup=profile->WireGroup;//这行报错,说是“TopoShapeGroup::WireGroup”: 无法访问 private 成员(在“TopoShapeGroup”类中声明),我按着网上的解决方案在TopoShapeGroup类中添加拷贝构造函数和重载=运算符都没有用,还是报错,求解答
.....
}