Initializing Arrays

  • Thread starter Thread starter Peter Oliphant
  • Start date Start date
P

Peter Oliphant

I'm using VC++ 2005 Express in /cli mode, and I'm trying to initialize an
array of integers. Something like:

array<int> int_array ;

int_array = gcnew array<int>(3) ;

int_array = { 0x3, 0x9, 0x7 } ; // error here

How is this done? Thanx in advance...
 
You can do one of:
array<int> ^int_array = { 0x3, 0x9, 0x7 };
or:
int_array = gcnew array<int>(3) { 0x3, 0x9, 0x7 };
or:
array<int> ^int_array = gcnew array<int>(3) { 0x3, 0x9, 0x7 };

i.e., the value initializer must occur in the same statement as array
creation.

--
David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
 
Back
Top