如何在 VC++/CLI 中实现 VB.net 中定义的接口
How to implement an interface defined in VB.net in VC++/CLI?
我有一个基于 VB.net 的界面,如下所示:
Namespace Foo
Public Interface Bar
ReadOnly Property Quuxes as Quux()
End Interface
End Namespace
我现在想在 VC++/CLI 中实现它(因为我需要从非托管的第三方 DLL 接口函数),但是我无法弄清楚如何实现它的正确语法。
这是我到目前为止拥有的头文件的相关部分:
namespace Foo {
public ref class ThirdPartyInterfacingBar : Bar {
public:
ThirdPartyInterfacingBar();
virtual property array<Quux^, 1>^ Quuxes;
};
}
但现在我被困在如何在随附的.cpp
文件中实现这一点。
当做类似的事情时(#include
剥离)
namespace Foo{
array<Quux^, 1>^ ThirdPartyInterfacingBar::Quuxes { /*...*/ }
}
我得到:C2048: function 'cli::array<Type,dimension> ^Foo::ThirdPartyInterfacingBar::Quuxes::get(void)' already has a body
我唯一能想到的就是这样的事情:
namespace Foo {
public ref class ThirdPartyInterfacingBar : Bar {
private:
array<Quux^, 1>^ delegateGetQuuxes();
public:
ThirdPartyInterfacingBar();
virtual property array<Quux^, 1>^ Quuxes {
array<Quux^, 1>^ get() {
return delegateGetQuuxes();
}
}
};
}
并在随附的 cpp 文件中实现delegateGetQuuxes
。但我认为这很丑陋,因为我不想在标题中有任何逻辑。有没有更好的方法?
看起来你只是忘记了get()。 正确的语法是:
.h file:
public ref class ThirdPartyInterfacingBar : Bar {
public:
property array<Quux^>^ Quuxes {
virtual array<Quux^>^ get();
}
};
.cpp file:
array<Quux^>^ ThirdPartyInterfacingBar::Quuxes::get() {
return delegateGetQuuxes();
}
相关文章:
- 如何在 64 位 vb.net Windows 应用程序中引用 32 位 dll
- 如何将 VB.Net 字符串作为字符*传递给C++dll?
- VB.NET DLL中的C++DLL函数复制
- TEA在VB.NET中的实现
- 如何使函数返回数组?用于制作在VB.NET中使用的DLL
- 反调试器技术:如何使用 VB.NET 对调试器隐藏线程?
- 如何在C 调用的VB.NET中编写回调函数
- 我可以在 vb.net Windows 窗体应用程序中使用 COLECONTROLModule 吗?
- C++ DLL 包装器 vb.net 传递字节数组的字节数组?
- 将简单的程序从C++移植到 vb.net
- 内存损坏从vb.net调用c dll
- vb.net单不等于c float
- 导入C 功能将结构的指针返回到VB.NET中
- REGDB_E_CLASSNOTREG from VB.NET to C++
- 使用来自VB.NET的参数调用C 函数
- 使用P/Invoke从MFC DLL函数中读取VB.NET中的结构化数据
- 将 C 按位语句转换为 vb.net
- C++ dll variable to vb.net exe
- 我无法读取 mft 并将 VB.net 转换为 C
- 在vb.net中调用C DLL文件