简单的 C 程序错误
Easy C Program Error
我正在编写一个非常简单的程序来显示 class 的模拟天气数据,但我无法弄清楚为什么 visual studio 总是给我一个错误
错误是温度通过它告诉我的方向:错误 C2440:'=':无法从 'double (__cdecl *)(void)' 转换为 'double'
我迷路了请帮忙
void DisplayWeatherData(void)
{
double temperature,humidity,pressure,windspeed,direction,bt,bp,bw;
temperature = GetTemperature;
humidity = GetHumidity;
pressure = GetPressure;
windspeed = GetWindspeed;
direction = GetWindDirection;
bt = (temperature * 9.0 / 5.0) + 32.0;
bp = pressure * KPATOINHG;
bw = windspeed * KMTOMPH;
printf("\nTemperature: %4.1lf C\tHumidity: %3.0lf%%\tPressure: %4.1lf kPa\n",temperature,humidity,pressure);
printf("Windspeed: %3.0lf km/hr\tDirection: %3.0lf Degrees\n\n",windspeed,direction);
printf("\nTemperature: %4.1lf F\tHumidity: %3.0lf%%\tPressure: %4.1lf inHg\n",bt,humidity,bp);
printf("Windspeed: %3.0lf mph\tDirection: %3.0lf Degrees\n\n",bw,direction);
}
double GetTemperature(void)
{
return 25.1;
}
double GetHumidity(void)
{
return 55.4;
}
double GetPressure(void)
{
return 101.7;
}
double GetWindspeed(void)
{
return 15.5;
}
double GetWindDirection(void)
{
return 320.0;
}
你在这里漏掉了括号:
temperature = GetTemperatur;
humidity = GetHumidity;
pressure = GetPressure;
windspeed = GetWindspeed;
direction = GetWindDirection;
应该是这样的:
temperature = GetTemperature();
.//same
.//same
.//same
direction = GetWindDirection();
我正在编写一个非常简单的程序来显示 class 的模拟天气数据,但我无法弄清楚为什么 visual studio 总是给我一个错误
错误是温度通过它告诉我的方向:错误 C2440:'=':无法从 'double (__cdecl *)(void)' 转换为 'double'
我迷路了请帮忙
void DisplayWeatherData(void)
{
double temperature,humidity,pressure,windspeed,direction,bt,bp,bw;
temperature = GetTemperature;
humidity = GetHumidity;
pressure = GetPressure;
windspeed = GetWindspeed;
direction = GetWindDirection;
bt = (temperature * 9.0 / 5.0) + 32.0;
bp = pressure * KPATOINHG;
bw = windspeed * KMTOMPH;
printf("\nTemperature: %4.1lf C\tHumidity: %3.0lf%%\tPressure: %4.1lf kPa\n",temperature,humidity,pressure);
printf("Windspeed: %3.0lf km/hr\tDirection: %3.0lf Degrees\n\n",windspeed,direction);
printf("\nTemperature: %4.1lf F\tHumidity: %3.0lf%%\tPressure: %4.1lf inHg\n",bt,humidity,bp);
printf("Windspeed: %3.0lf mph\tDirection: %3.0lf Degrees\n\n",bw,direction);
}
double GetTemperature(void)
{
return 25.1;
}
double GetHumidity(void)
{
return 55.4;
}
double GetPressure(void)
{
return 101.7;
}
double GetWindspeed(void)
{
return 15.5;
}
double GetWindDirection(void)
{
return 320.0;
}
你在这里漏掉了括号:
temperature = GetTemperatur;
humidity = GetHumidity;
pressure = GetPressure;
windspeed = GetWindspeed;
direction = GetWindDirection;
应该是这样的:
temperature = GetTemperature();
.//same
.//same
.//same
direction = GetWindDirection();