2009-06-17 3 views
1

어떻게? 선언C++/CLI에서 델리게이트를 전달하는 방법은 무엇입니까?

delegate MyDelegate; 
ref class MyDelegate; 
delegate void MyDelegate; 

다음 작품 :

다음은 작동하지 않았다

public delegate void MyDelegate(Object ^sender, MyArgs ^args); 

을하지만 앞으로 선언으로 사용하는 것은 나에게주는

error C3756: 'MyNameSpace::MyDelegate': delegate definition conflicts with an existing symbol 
+0

하나의 제안은 앞으로 MyArgs를 선언하는 것이었지만 심지어 도움이되지 못했습니다. 누군가 제발 도와 줄 수 있니? –

답변

1

나를 위해이 작품의 ;

에 stdafx.h :

public delegate void Handler(bool isit); 

cli1.cpp :

#include "stdafx.h" 
using namespace System; 

namespace MY { 
    namespace Namespace 
    { 
     public ref class Objeks 
     { 
      public: Objeks() {} 
      public: event Handler^ OnHandler; 
      public: void __clrcall Runner(bool checkit) 
      { 
       if(&Objeks::OnHandler != nullptr) 
       OnHandler(checkit); 
      } 
     }; 
    } 
} 

내가 대부분 2010 C++/CLI 프로젝트 만 기본 VS 왼쪽, 나는 당신이 겪고있는 경우 것으로 기대 앞으로 선언의 문제, using 네임 스페이스 시스템; 헤더에 또한 갈 것입니다 :)

아마 당신은 이벤트를 사용하고 싶지 않았습니까? 그러나 그것은 단순히 구조로 보인다.

(Error Compiling C++/CLI Delegate call using Predicate with Array::FindAll())을 고려한 후 오류 검사를 추가했습니다.

관련 문제