I get this error in my c++ code Variable length array of non-POD element type string
(aka basic_string
).
string words[n
C++ doesn't have C99-style variable length arrays. Your compiler might support them as an extension, but they're not part of the language. In this specific case, your success with Visual Studio indicates that it does in fact have such an extension. clang++ will support VLAs, but only of POD types, so your attempt to make a VLA of string
objects won't work. g++ does work on my machine if I leave off enough warning/error flags.