Ars*_*ray 1 c++ managed-c++ interface
这是我声明的界面:
[ServiceContract]
public interface class IShedluer
{
[OperationContract]
array<Object^>^ GetResult(UInt64 taskId);
}
Run Code Online (Sandbox Code Playgroud)
这是尝试实现它的类:
ref class MyShedluer:IShedluer
{
Shedluer ^shedluer;//this is NOT MyShedluer
public:
MyShedluer(void);
array<Object^>^ GetResult(UInt64 taskId)
{
return shedluer->GetResult(taskId);
}
}
Run Code Online (Sandbox Code Playgroud)
当我试图编译这个时,我得到了
Error 15 error C3766: 'MyShedluer' must provide an implementation for
the interface method 'cli::array<Type> ^IShedluer::GetResult(unsigned __int64)'
d:\users\menkaur\documents\visual studio 2010\projects\MyProject\
\kernel\MyShedluer.h 78 1 MyProject.Kernel
Run Code Online (Sandbox Code Playgroud)
我为什么要这个?
实现接口的正确语法是添加virtual:
ref class MyShedluer:IShedluer
{
public:
virtual array<Object^>^ GetResult(UInt64 taskId);
}
Run Code Online (Sandbox Code Playgroud)
编译器也告诉你,看看你的警告:
warning C4488: 'MyShedluer::GetResult' : requires 'virtual' keyword
to implement the interface method 'IShedluer::GetResult'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2983 次 |
| 最近记录: |