I did `g++ -std=c++11 main.cpp gettoken.cpp` but I'm still getting the same error.
@ne555 Sorry, what did you mean? What did you add to the posted code that would make it compile without errors? This is my first C++ class, please forgive me.
I copied the code from my original post into a clean folder and ran g++ -std=c++11 main.cpp gettoken.cpp and got that. All 3 files are directly under that folder. Thank you for your patience.
Ok, I just tried it on the school system (Linux)--g++ -std=c++11 main.cpp gettoken.cpp results in an unrecognized command line option error while g++ -std=c++0x main.cpp gettoken.cpp compiles.
Both commands result in the error mentioned earlier on my Windows machine. This is so bizarre, still trying to figure out what's the problem because I need to code and compile on the Windows machine but at least I can compile. Maybe I need to get a new compiler... Thank you anyway.
As an aside, sounds like your school system should think about getting a more recent version. The first version of the GCC that recognised -std=c++11 was 4.7, exactly four years ago (March 2012), so what you've got there is something older than that.
As another hopefully useful aside, always compile with a high level of warnings, as a minimum use -Wall -Wextra -pedantic-errors and optionally (but useful) those extra ones that I mention here:
Note that I mention the latest standard being c++14, you could substitute in the latest one that a compiler supports, as in -std=c++0x on your school system. I also mention clang++, but that is generally very similar to g++.
Here is a description of the extra ones, which I copied from the gcc5.3 manual:
A lot of those warning options have been around a long time, they should still work on the older compilers. If in doubt read the manual for the particular version of compiler being used. The gcc web page has complete and separate documentation for each distinct version.
IMO clang is slightly better than gcc, consider getting it yourself - AFAIK it can be integrated into IDE's on Windows. It might be worth mentioning it to your school too - hopefully not too much of a drama to install it, and it's free. To install directly, it might need a fairly recent version of Linux - something less than 3 versions old. In any case I am sure the sys admins would hopefully be all over that.
Yup, turns out installing MinGW's 64-bit variant (the provider of this 64-bit variant continues to develop MinGW, as opposed to the provider of the 32-bit variant whose development has stopped a few years ago) fixed it. Also, I read that clang compiles code noticeably faster than gcc in general and gcc tends to optimize the code marginally better on some occasions. For my purposes, seems like clang is the best choice--gcc can still be used to optimize the code for the finished product.