I am currently using Visual Studio Community 2017. From looking at the C++ Language Standards in the project properties, they only provide C++14 and C++17. Since my code was
C++ is an evolving standard - after 2003 there was 2011 (C++11) then 2014 (C++14) and now we have 2017 (C++17) and we're working towards 2020 (C++20). They're upward compatible.
Look here for Microsoft Visual C++ support for the various standards.
Microsoft I think has declared that
Note that there is no plan to add a C++11 switch. link
So there's not an explicit switch
As an update to this, VS 2017, Update 9.4 (releasd Dec 2018) is now fully C++17 compliant.
The Visual C++ 2017 compiler is C++11/C++14 compliant with a few specific exceptions:
The compiler does not offer a specific C++11 mode and defaults to C++14, but that standard is fully inclusive of C++11. C++17 support is in progress, and requires you use the /std:c++17 or /std::c++latest
switch.
std::stoi
requires you include the appropriate header, specifically <string>>
Either you forgot to include that header -or- you didn't deal with the namespace
resolution (either explicitly as std::
or via using namespace std;
)
See C++17 Features And STL Fixes In VS 2017 15.3 for the latest status of C++11/C++14/C++17 standards conformance as of the VS 2017 (15.3 update)
UPDATED: Now that you have posted your code, I see that the problem has nothing to do with which standard is supported. Your problem is that you don't know the secrets of how Precompiled Headers work.
Change:
#include <string>
#include "stdafx.h"
to:
#include "stdafx.h"
#include <string>
-or- add #include <string>
to the precompiled header stdafx.h
directly.
See Creating Precompiled Header Files