需要帮助使用源代码C ++识别问题(标题,结构,类复杂)

时间:2016-10-15 04:43:07

标签: c++

错误:" WeatherForecaster的原型:: WeatherForecaster(std ::所有变量)与WeatherForecaster中的任何类都不匹配" 我没有关于如何避免这种情况的想法。我的主要代码与错误btw无关。

最近的错误,其余是固定的。我现在在main"没有匹配的函数中得到错误来调用WeatherForecast :: WeatherForecast()"。在我创建变量wf WeatherForecast之后。

来源:

#include "WeatherForecaster.h" //header being included
#include<iostream>
using namespace std;

//error comes here 
WeatherForecaster::WeatherForecaster(string d, string fd, int h, int l,      
int hum,int avgw, string avgwd, int maxw, string maxwd, double p)
{

string day=d;
string forecastDay=fd;
int highTemp=h;
int lowTemp =l;
int humidity=hum;
int avgWind= avgw;
string avgWindDir=avgwd;
int maxWind=maxw;
string maxWindDir= maxwd;
double recip=p;
}
WeatherForecaster::~WeatherForecaster(){

    //dtor
};//end of block of source code

标题:我犯了这么简单的错误,我只是不确定它究竟是什么。

#ifndef WEATHERFORECASTER_H
#define WEATHERFORECASTER_H

#include <iostream>
using namespace std;

//does my code have a problem with how it interacts with this struct?
struct ForecastDay{
std::string day;
std::string forecastDay;
int highTemp;
int lowTemp;
int humidity;
int avgWind;
std::string avgWindDir;
int maxWind;
std::string maxWindDir;
double precip;

};

class WeatherForecaster

{
public://most recent error ") expected before 'd'"
    WeatherForecaster(string d, string fd, int h, int l,
 int hum,int avgw, string avgwd, int maxw, string maxwd, double p);
    ~WeatherForecaster();
    void addDayToData(ForecastDay);
    void printDaysInData(); 
    void printForecastForDay(std::string);
    void printFourDayForecast(std::string);
    double calculateTotalPrecipitation();
    void printLastDayItRained();
    void printLastDayAboveTemperature(int); //argument is the    
     temperature
    void printTemperatureForecastDifference(std::string);
    void printPredictedVsActualRainfall(int); 
    std::string getFirstDayInData();
    std::string getLastDayInData();

 protected:
 private:
    int arrayLength;
    int index;
    ForecastDay yearData[984]; 
 };

#endif // WEATHERFORECASTER_H

2 个答案:

答案 0 :(得分:-1)

构造函数的声明在标题中采用这些参数(字符串d,字符串fd,int h,int l,int hum,int avgw,string avgwd,int maxw,string maxwd,double p)在哪里?

答案 1 :(得分:-1)

正如错误消息所述:你需要为&#34; WeatherForecaster添加原型(字符串d,字符串fd,int h,int l,int hum,int avgw,string avgwd,int maxw,string maxwd,double p)&#34;在你的WeatherForecaster课程中。