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

user4469411

I am getting a C++/CLI array type is not allowed here error when using array type in a class. First I have created a Console application in Visual Studio 2013 and added a new class "MainClass". Then I added a new method. The thing is that I used array in the same project in the main cpp file with no classes with no problems and it seems like it's being used the same way in this example. Here's 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;
}
Hans Passant
    bool Verify(array<System::Byte> DataToVerify);

Knowing when to use the ^ hat is super-duper important in C++/CLI. And compile errors not exactly fantastic when you don't use it properly. Arrays are reference types, omitting the hat is not optional here when you pass the array as an argument. It is in fact never optional, stack semantics on managed arrays doesn't make sense since they are not disposable. Fix:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Intel C++ compiler (icpc 14.0): "a derived class is not allowed here"

From Dev

C# Struct array but not class array

From Dev

C++/CLI Interface is not visible from my C# Class

From Dev

C: Allowed to assign any array to pointer to array of incomplete type

From Dev

Allocating an array of a class c++

From Dev

C++ incomplete type is not allowed class inner use?

From Dev

using keyword with class not allowed?

From Dev

Are class names allowed to be lower case

From Dev

C++: Error: Indirect nonvirtual base class is not allowed

From Dev

How to convert C++/CLI array to String or standard C array

From Dev

C++/Cli literal Array Initialization

From Dev

Wrapping C++ CLI Class For C#

From Dev

explicit typecasting of a C# class in C++/CLI

From Dev

C++ pointer to incomplete class type is not allowed

From Dev

What are the allowed types for an enum (class)?

From Dev

friend not allowed outside of a class definition

From Dev

Is mixing the old and new C++ function syntax in a class allowed?

From Dev

Array initializer is not allowed here

From Dev

Allocating an array of a class c++

From Dev

C++/Cli literal Array Initialization

From Dev

How to convert C++/CLI array to String or standard C array

From Dev

Wrapping C++ CLI Class For C#

From Dev

explicit typecasting of a C# class in C++/CLI

From Dev

C# Array list with class

From Dev

Search array of a class c#

From Dev

Creating multidimensional Tuple array in C++/Cli

From Dev

C++ error: object of abstract class type is not allowed

From Dev

How to order an array in managed C++/CLI

From Dev

C# Class (array?) issues

Related Related

HotTag

Archive