Really Easy Help needed Managed c++ syntax for declaring array of unsigned long 
Author Message
 Really Easy Help needed Managed c++ syntax for declaring array of unsigned long

I am not a c++ person so please forgive this really basic question.

I need to declare an unsigned long array with 256 positions

in C# you would do something like
Byte[] buffer = new Byte[256]; for a Byte array

I am trying to declare this in the header file of a managed class with the
syntax of "static unsigned long __gc variablename[256];" I get an error

error C3150: 'variablename' : '__gc' can only be applied to a class, struct,
interface, array or pointer

If i take the __gc out i get an error

error C2697: 'variablename' : must explicitly specify __gc or __nogc for an
array declared in a managed type

I need an array that is equivalent to a private variable.

Here is the code in my header

public __gc class classname

{

// TODO: Add your methods for this class here.

protected:

//static unsigned long[256] __gc crc32_table = new unsigned long[256]; //
Lookup table array

static unsigned long __gc variablename[256]; // Lookup table array

//Other stuff below that works fine.

Quote:
};

Thank you

Joe Feser



Thu, 02 Sep 2004 03:12:36 GMT  
 Really Easy Help needed Managed c++ syntax for declaring array of unsigned long
Joe Feser:

Quote:
> in c# you would do something like
> Byte[] buffer = new Byte[256]; for a Byte array

> I am trying to declare this in the header file of a managed class with the
> syntax of "static unsigned long __gc variablename[256];" I get an error

   I remember getting very confused by the positioning of the __gc. I don't
have an exact equivalent but here is a declaration that works

char body __gc[];

   then in the constructor

body = new char __gc[256];

Quote:
> //static unsigned long[256] __gc crc32_table = new unsigned long[256]; //
> Lookup table array

   For statics you may merge the allocation into the declaration:

static char b __gc[] = new char __gc[256];

   Neil



Thu, 02 Sep 2004 05:59:42 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need help with Managed arrays in C++...

2. Newbie needs help: Managing ActiveX exe server instancing / IIS (long)

3. unsigned long to long without lossage (Help)

4. Need help declaring an array of strings

5. HELP NEEDED to declare very large global array

6. Help making a really big array needed

7. Need help declaring an array.

8. Need help with syntax for passing an array byref

9. really need C++ help

10. Array of bytes to unsigned longs problem....

11. really need C++ help

12. How to declare a managed class pointer from unmanaged c++

 

 
Powered by phpBB® Forum Software