__gc array initializers?

  • Thread starter Thread starter Tom
  • Start date Start date
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
 
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?
 
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?
 
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)
 
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
 
Back
Top