c++的简单问题

来源:百度知道 编辑:UC知道 时间:2024/05/10 19:36:08
刚刚学到类,有点不懂,希望高手们帮下忙。

#include <iostream>
using namespace std;
#include "Temperature.h"

int main()
{
cout <<"To convert Fahrenheit to Celsius, \n"
<<"enter a Fahrenheit temperaturn:";
double fahrTemp;
cin >>fahrTemp;

double selsTemp = Temperature::fahrToCels(fahrTemp);

cout <<"The equivalent temperature is" <<celsTemp <<endl;
}

/********************************/
下面的是类文件:

#include <cassert>
using namespace std;

const double MIN_FAHRENHEIT =-459.67,
MIN_CELSIUS =-273.15,
MIN_KELVIN =0;

class Temperature
{
public:
static double fahrToCels(double tempFahr);
static double fahrToKelv(double tempFahr);
static double celsToFahr(double tempCels);
static double celsToKelv(double tempCels);
static double kelv

楼上的朋友已经给你改正了错误, 如果你还不清楚的话我就给你标注下你错的地方:

#include <iostream>
using namespace std;
#include "Temperature.h"

int main()
{
cout <<"To convert Fahrenheit to Celsius, \n"
<<"enter a Fahrenheit temperaturn:";
double fahrTemp;
cin >>fahrTemp;

// 下面应该是double celsTemp吧...
double selsTemp = Temperature::fahrToCels(fahrTemp);

cout <<"The equivalent temperature is" <<celsTemp <<endl;
}

/********************************/
下面的是类文件:

#include <cassert>
using namespace std;

const double MIN_FAHRENHEIT =-459.67,
MIN_CELSIUS =-273.15,
MIN_KELVIN =0;

class Temperature
{
public:
static double fahrToCels(double tempFahr);
static double fahrToKelv(double tempFahr);
static double celsToFahr(double tempCels);
static