Array not allowed in class in C ++ / CLI?

I get a C ++ / CLI array type, no error is made here when using an array type in a class. First, I created a console application in Visual Studio 2013 and added a new class, "MainClass". Then I added a new method. The thing is, I used an array in the same project in the main cpp file without classes without problems, and it looks like it is used in the same way in this example . Here is MainClass.h:

#pragma once #using <System.dll> #using <System.Security.dll> #include <windows.h> using namespace System; using namespace System::Security; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::X509Certificates; using namespace System::IO; using namespace System::Collections::Generic; ref class MainClass { public: MainClass(); bool Verify(array<System::Byte> DataToVerify); }; 

MainClass.cpp:

 #include "MainClass.h" #using <System.dll> #using <System.Security.dll> #include <windows.h> using namespace System; using namespace System::Security; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::X509Certificates; using namespace System::IO; using namespace System::Collections::Generic; MainClass::MainClass() { } bool MainClass::Verify(array<System::Byte> DataToVerify) { return false; } 
+5
source share
1 answer
  bool Verify(array<System::Byte> DataToVerify); 

Knowing when to use ^ hat, this is a super-duper, important in C ++ / CLI. And compiling errors is not entirely fantastic when you are not using it properly. Arrays are reference types; lowering the hat is not necessary here when you pass an array as an argument. This is actually never mandatory, the semantics of the stack on managed arrays does not make sense, since they are not disposable. Fix:

  bool Verify(array<System::Byte>^ DataToVerify); 
+12
source

Source: https://habr.com/ru/post/1214312/


All Articles