__gc array initializers?

T

Tom

Does anyone know if the 2005 version of C++.NET will support the traditonal
C-style
way of initializing arrays at the declaration? [avoiding the dreaded
C3184].

-- Tom
 
T

Tomas Restrepo \(MVP\)

Hi Tom,
Does anyone know if the 2005 version of C++.NET will support the traditonal
C-style
way of initializing arrays at the declaration? [avoiding the dreaded
C3184].

What do you mean by this? This?

String* ar __gc[] = { S"asdasd", S"adadsasd", S"scasdsda" };

That already works.... or what?
 
T

Tom

Yes - that is what I am trying to do, buy it gives me a compile error in VC++.NET 2003:
"error C3845: only static data members can be initialized inside a __gc class or value type"

-- Tom



Tomas Restrepo (MVP) said:
Hi Tom,
Does anyone know if the 2005 version of C++.NET will support the traditonal
C-style
way of initializing arrays at the declaration? [avoiding the dreaded
C3184].

What do you mean by this? This?

String* ar __gc[] = { S"asdasd", S"adadsasd", S"scasdsda" };

That already works.... or what?
 
T

Tomas Restrepo \(MVP\)

Tom,
<<
Yes - that is what I am trying to do, buy it gives me a compile error in
VC++.NET 2003:
"error C3845: only static data members can be initialized inside a __gc
class or value type"
Are you trying to initialize inline a non-static class member like this? If
so, no, you are right that won't work (and won't work for unmanaged types
either in C++ classes, either)
 
T

Tom

Tomas,
You are correct - I was trying to initialize a class array variable that
was not static.
Declaring the variable as static turned out to be the correct thing to
do anyway.
Thanks for the help.

-- Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top