请看下面的代码
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
bool isEven(int);
int number;
vector<int> inputNumbers;
string line;
int main()
{
cout << "Please enter numbers: ";
getline(std::cin,line);
istringstream iss(line);
while(iss>>number)
{
inputNumbers.push_back(number);
}
size_t vectorSize = inputNumbers.size();
for(int i=0;i<vectorSize;i++)
{
cout << "Result for number " << i << "is: " << isEven(inputNumbers(i));
}
}
bool isEven(int number)
{
if(number%2 == 0)
{
return true;
}
else
{
return false;
}
}
当我运行这个程序时,它给出了以下错误
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Users/yohan/Documents/NetBeansProjects/Excersice 6'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/excersice_6.exe
make[2]: Entering directory `/cygdrive/c/Users/yohan/Documents/NetBeansProjects/Excersice 6'
mkdir -p build/Debug/Cygwin-Windows
rm -f build/Debug/Cygwin-Windows/EvenNumbers.o.d
g++ -c -g -MMD -MP -MF build/Debug/Cygwin-Windows/EvenNumbers.o.d -o build/Debug/Cygwin-Windows/EvenNumbers.o EvenNumbers.cpp
EvenNumbers.cpp: In function `int main()':
EvenNumbers.cpp:32: error: no match for call to `(std::vector<int, std::allocator<int> >) (int&)'
make[2]: *** [build/Debug/Cygwin-Windows/EvenNumbers.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
nbproject/Makefile-Debug.mk:79: recipe for target `build/Debug/Cygwin-Windows/EvenNumbers.o' failed
make[2]: Leaving directory `/cygdrive/c/Users/yohan/Documents/NetBeansProjects/Excersice 6'
nbproject/Makefile-Debug.mk:62: recipe for target `.build-conf' failed
make[1]: Leaving directory `/cygdrive/c/Users/yohan/Documents/NetBeansProjects/Excersice 6'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
BUILD FAILED (exit value 2, total time: 1s)
如果我删除对 isEven() 的函数调用,这将不会发生。为什么会这样?请帮忙!