我只是想看看我是否能读取文本文件和显示,但我有此错误:C++错误LNK 2019
2 error LNK2019: unresolved external symbol "public: void __thiscall WeatherReport::displayReport(void)" ([email protected]@@QAEXXZ) referenced in function _main
谁能给我解释一下是什么原因造成这一点,为什么发生这种情况,以及如何解决这个问题?
#include<fstream>
#include<iomanip>
#include<stdio.h>
#include<cmath>
#include<iostream>
using namespace std;
class WeatherReport
{
WeatherReport friend monthEnd(WeatherReport, WeatherReport);
private:
int dayofMonth;
int highTemp;
int lowTemp;
double amoutRain;
double amoutSnow;
public:
WeatherReport(int Day = 0);
void setValues(int, int, int, double, double);
void getValues();
void displayReport();
}
void WeatherReport::setValues(int dom, int ht, int lt, double ar, double as)
{
dayofMonth = dom;
highTemp = ht;
lowTemp = lt;
amoutRain = ar;
amoutSnow = as;
}
int main()
{
const int DAYS = 30;
WeatherReport day[DAYS];
WeatherReport summary;
int i = 0;
ifstream inFile;
inFile.open("WeatherTest.txt");
if (!inFile)
cout << "File not opended!" << endl;
else
{
int dom, ht, lt;
double ar, as;
while (inFile >> dom >> ht >> lt >> ar >> as)
{
day[i].setValues(dom, ht, lt, ar, as);
i++;
}
inFile.close();
for (int i = 0; i < DAYS; i++)
{
day[i].displayReport();
//read one line of data from the file
//pass the data to setValues to initialize the object
}
system("PAUSE");
return 0;
}
是的,它是重复的,队长Obv ......等等。说真的,这个问题已经被***问过很多次了。 ***查看我的个人资料'关于我'***。 – cybermonkey 2014-11-02 20:28:49
-1可怕的凹痕 – GingerPlusPlus 2014-11-02 20:31:28
好的,谢谢。一些我没有看到的。感谢您的链接 – Meene 2014-11-02 20:39:27