我一直在尝试运行使用stoi的代码,下面是makefile,每次运行此代码时,我都会收到“错误:此范围内未声明'stoi'”,无论如何我都可以包含生成文件中的C ++ 11编译器
#compile and link the application
all: main
#run the application
run: main
./main
#link main.o, time.o, and date.o to excutuable main, with debug messages
and functions visible
debug: temp.o day.o cal.o
g++ -g -c -Duse_debug main.cpp
g++ -g -o main main.o temp.o day.o cal.o
#link main.o, temp.o, and day.o to executable main
main: main.o temp.o day.o cal.o
g++ -g -o main main.o temp.o day.o cal.o
#compile the main.cpp to main.o
main.o: main.cpp
g++ -g -c main.cpp
#compile the temp.cpp to temp.o
temp.o: temp.cpp
g++ -g -c temp.cpp
#compile the day.cpp to day.o
day.o: day.cpp
g++ -g -c day.cpp
#compile the cal.cpp to cal.o
cal.o: cal.cpp
g++ -g -c cal.cpp
#remove built files
clean:
rm -rf main main.o temp.o day.o cal.o *~
这是使用stoi的零件的示例代码,
#include <iostream> //cin and cout
#include <string> //stoi(), getline()
#include <cctype> //isdigit()
using namespace std;
int main()
{
int input;
string inputS;
cin>> inputS;
input = stoi(inputS); //converts inputStr to int type
return 0;
}