I’m a programming student in my first C++ class, and for a recent project I did, I was unable to create an array of strings like I could do in C#:
string MONTHS[ARRAY_CAPACITY] = { "Jan", "Feb", "Mar", "April", "May", "June", "July", "Aug", "Sep", "Oct", "Nov", "Dec" };
// this yields many compiler errors in C++
Is it possible to do something similar in C++?
Thanks!
If you initialise the array in C++ then it doesn’t require a size to be set (although it’ll accept one), so:
compiles fine with g++ for me and I’d expect it to compile elsewhere too. I expect your errors are due to the lack of
std::namespace.