void f(cli::array<PointF> ^points){
PointF& a = points[0];
// and so on...
}
第 2 行出现编译错误。
.\ndPanel.cpp(52) : error C2440: 'initializing' : cannot convert from 'System::Drawing::PointF' to 'System::Drawing::PointF &'
An object from the gc heap (element of a managed array) cannot be converted to a native reference
声明引用变量的托管方式是什么?
最佳答案
如果您只想声明对数组中第一个 PointF 的引用,那么您需要使用 tracking reference (%):
void f(cli::array<PointF>^ points)
{
PointF% a = points[0];
}
关于.net - C++/CLI 引用变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/245957/