“To_string ‘was not declared in this scope” is sometimes encountered when using CodeBlocks (the compiler adopts MinGW) under windows Code blocks, to_ String and so on, which only introduces the parts and solutions related to this problem
first, to_String is a new function introduced by C + + 11, which may not be supported by the old compiler, so “C + + 11” compilation support should be added to the compiler: open Settings -> Compiler
Check the C + + 11 standard here
of course, you should also check your code for problems. to_String is contained in string, and string is contained in space STD, so your code should include header file and related space introduction, for example:
#include <iostream> #include <string> //std::string std::to_string using namespace std; int main() { int a = 123; cout << "a = " << to_string(a) <<endl; // If you don't add namespaces you can use std::to_string here return 0; }
Similar Posts:
- C++ write and read file via fstream in ios::out,ios::in,ios::app mode
- QT use of undeclared identifier ‘cout’
- C++ Error: passing ” “as” ” discards qualifiers
- [Solved] OpenCV 4 (C++) Error: “error: ‘CV_FOURCC’ was not declared in this scope”
- [Solved] C++ get file size via ifstream and set mode as ios::ate
- C++ 11: How to Avoid Deadlock in unique_Lock and lock_Guard
- [Solved] Clang: error: linker command failed with exit code 1
- C++ error: cannot bind non-const lvalue reference of type ‘myString&’ to an rvalue of type ‘m…
- error: ‘to_string’ was not declared in this scope
- C write and read file via FILE and open method in a+ or r mode