2012-01-19 21 views
1

は、私が宣言したインタフェースです。ここマネージC++でインターフェイスを実装する方法は?ここ

[ServiceContract] 
public interface class IShedluer 
{ 
    [OperationContract] 
    array<Object^>^ GetResult(UInt64 taskId); 
} 

はそれを実装しようとしているクラスです。

ref class MyShedluer:IShedluer 
{ 
    Shedluer ^shedluer;//this is NOT MyShedluer 
public: 
    MyShedluer(void); 

    array<Object^>^ GetResult(UInt64 taskId) 
    { 
     return shedluer->GetResult(taskId); 
    } 
} 

私はこれをコンパイルしようとしているとき、私は

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 
を取得しています

なぜ私はこれを取得していますか?

答えて

5

インタフェースを実装するための正しい構文はvirtualを追加することです:

warning C4488: 'MyShedluer::GetResult' : requires 'virtual' keyword 
to implement the interface method 'IShedluer::GetResult' 

はまた、コンパイラは、この、同様にあなたの警告を見てわかります
ref class MyShedluer:IShedluer 
{ 
public: 
    virtual array<Object^>^ GetResult(UInt64 taskId); 
} 

関連する問題