i have a c++ CLR app im creating and i cant declare my string array for some reason. im using namespace system(not to familiar with it).
the error message says "The declaration has no storage or type specifier"
private:
string[] folderFile = null;
int selected = 0;
int begin = 0;
int end = 0;
To create an array of C++ strings, the syntax is:
std::string folderFile[length]; // not a pointer, cannot be nullptr
To create a pointer to an array of C++ strings, so you can set the length when you create it:
std::unique_ptr<std::string[]> folderFile; // initially nullptr
To create a (tracking reference to a) CLR array of (tracking references to) CLR strings, the syntax is:
array<System::String^>^ folderFile;
The first two options can only be used in a C++ class (class
or struct
), while the last one is only for CLR classes (ref class
, value struct
and the like).