错误消息:C++错误C2040?
这是什么意思?
我该如何解决?
错误C2040: '==': '诠释' 的不同之处,从 '为const char [2]'
代码间接的层次:
#include <iostream>
#include <cmath>
using namespace std;
int round(double number);
//Assumes number >=0.
//Returns number rounded to the nearest integer.
int main()
{
double doubleValue;
char ans;
do
{
cout << "Enter a double value: ";
cin >> doubleValue;
cout << "Rounded that number is " <<round(doubleValue)<< endl;
cout << "Again? (y/n): ";
cin >> ans;
}
//Here is the line generating the problem, while(...);
while (ans == 'y' || ans == "Y");
cout << "End of testing.\n";
return 0;
}
//Uses cmath
int round(double number)
{
return static_cast<int>(floor(number + 0.5));
}
我一看到问题就看到了问题,但这是一个非常无益的编译器错误消息。不难理解为什么人们会对C及其同类感到沮丧。 – 2010-01-02 08:58:27