This problem is mainly caused by the different versions of the C++ compiler. You can refer to the vector error report , and you need to specify the C++ version when compiling.
If you use vscode as the editor and use the code runner plugin, you can modify the configuration of the plugin "Executor Map".
The cpp line is changed to:
# -std用于指定C++编译器版本
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++11 && $dir$fileNameWithoutExt"
Of course, you can also execute g++ commands directly on the command line.