L
longbrmb
I'm new to C++/CLI and my main background is Java. I'm trying to
create an array of constants as a static member of a class. An
example is shown below:
public ref class TestClass {
public:
static const array<constant int>^ stuff = {1,2,3,4,5};
};
This gives me compiler error C4538 which basically says that you can't
declare an array as constant. So that means that the values in my
array can't be changed, but nothing stops someone from assigning a new
array to the "stuff" variable. Am I missing something or is it not
possible to create a fixed array of constants?
create an array of constants as a static member of a class. An
example is shown below:
public ref class TestClass {
public:
static const array<constant int>^ stuff = {1,2,3,4,5};
};
This gives me compiler error C4538 which basically says that you can't
declare an array as constant. So that means that the values in my
array can't be changed, but nothing stops someone from assigning a new
array to the "stuff" variable. Am I missing something or is it not
possible to create a fixed array of constants?