c++ cli - C++/Cli literal Array Initialization -


i'm trying create constant array in managed c++ , getting stuck. i've searched around haven't come across examples of how this.

what i'd equivalent of:

const unsigned char myconstarray = {1,2,3,4,5,6}; 

right i'm staring @ this:

literal array<byte>^ myconstarray = gcnew array<byte> { 1,2,3,4,5,6}; 

which gather not right, since visual studio complains cannot use gcnew in constant expression. not sure go here, appreciated.

cheers,

david

it not work literal because:

a data member marked literal must initialized when declared , the value must constant integral, enum, or string type. conversion type of initialization expression type of static const data-member must not require user-defined conversion.

literal (c++ component extensions)

...however quite strange literal an equivalent of static const using static const compiles without errors.

creating read-only property way return array:

ref class test1 { public:     test1() {         myarray = gcnew cli::array<byte> { 1, 2, 3, 4, 5, 6};     }      property cli::array<byte>^ myarray {         cli::array<byte>^ get() {             return myarray;         };       }  private:      cli::array<byte>^ myarray;  }; 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -