fork download
  1. using namespace System;
  2.  
  3. namespace Delegate
  4. {
  5. ref class Hoge
  6. {
  7. public:
  8. event EventHandler^ Piyo;
  9. Hoge() { }
  10. void Raise() { Piyo(nullptr, EventArgs::Empty); }
  11. };
  12.  
  13. ref class Program
  14. {
  15. static void Main()
  16. {
  17. Hoge^ hoge = gcnew Hoge;
  18. hoge->Piyo += gcnew EventHandler(&Hoge1);
  19. hoge->Piyo += gcnew EventHandler(&Hoge2);
  20. hoge->Piyo += gcnew EventHandler(&Hoge3);
  21. hoge->Raise();
  22.  
  23. auto mcd = (MulticastDelegate^)hoge->Piyo;
  24. auto list = mcd->GetInvocationList();
  25. }
  26.  
  27. static void Hoge1(Object^ sender, EventArgs^ e) { System::Diagnostics::Debug::Print("Hope1"); }
  28. static void Hoge2(Object^ sender, EventArgs^ e) { System::Diagnostics::Debug::Print("Hope2"); }
  29. static void Hoge3(Object^ sender, EventArgs^ e) { System::Diagnostics::Debug::Print("Hope3"); }
  30. };
  31. }
  32.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:17: error: ‘System’ is not a namespace-name
 using namespace System;
                 ^
prog.cpp:1:23: error: expected namespace-name before ‘;’ token
 using namespace System;
                       ^
prog.cpp:5:2: error: ‘ref’ does not name a type
  ref class Hoge
  ^
prog.cpp:13:2: error: ‘ref’ does not name a type
  ref class Program
  ^
stdout
Standard output is empty