My compiler keeps saying LNK2019, and my teacher says to look for spelling error. He says that most likely what is happening is that a spelling error is messing my program up. I searched, and I did not find a spelling error though...
This is what my error message looks like
error LNK2019: unresolved external symbol "public: __thiscall weatherStationS ystem::weatherS tationSystem(vo id)" (??0weatherStat ionSystem@@QAE@ XZ) referenced in function "public: __thiscall weatherSystemUI ::weatherSystem UI(void)" (??0weatherSyst emUI@@QAE@XZ)
1>C:\Users\yuhw achiang\Documen ts\Visual Studio 2008\Projects\L ab Six\Debug\Lab Six.exe : fatal error LNK1120: 1 unresolved externals
And my code is below. Thank you so much if you can figure this out. This lab is due by 11PM today, so I would really like to get it done.
This is what my error message looks like
error LNK2019: unresolved external symbol "public: __thiscall weatherStationS ystem::weatherS tationSystem(vo id)" (??0weatherStat ionSystem@@QAE@ XZ) referenced in function "public: __thiscall weatherSystemUI ::weatherSystem UI(void)" (??0weatherSyst emUI@@QAE@XZ)
1>C:\Users\yuhw achiang\Documen ts\Visual Studio 2008\Projects\L ab Six\Debug\Lab Six.exe : fatal error LNK1120: 1 unresolved externals
And my code is below. Thank you so much if you can figure this out. This lab is due by 11PM today, so I would really like to get it done.
Code:
#include <iostream> #include <string> #include <vector> #include <iomanip> #include <fstream> using namespace std; class pollenCount { protected: double dailyHigh; double dailyLow; public: pollenCount() {dailyHigh = dailyLow = 0; } void setHighCount(double highPollen) { dailyHigh = highPollen; } void setLowCount(double lowPollen) { dailyLow = lowPollen; } double getHighCount() { return dailyHigh; } double getLowCount() { return dailyLow; } double getMeanCount() { return (dailyHigh + dailyLow)/2; } }; class weatherStation : public pollenCount { string stationDesignation; string stationContact; double stationTemperature; public: weatherStation(); weatherStation(string, string, double); void setDesignation(string ID) {stationDesignation = ID;} void setContact(string Contact) {stationContact = Contact;} void setTemperature(double temperature) {stationTemperature = temperature;} string getDesignation() {return stationDesignation;} string getContact() {return stationContact;} double getTemperature() {return stationTemperature;} }; weatherStation::weatherStation() { stationDesignation = ""; stationContact = ""; stationTemperature = 0.0; } weatherStation::weatherStation(string ID, string contact, double temperature) { stationDesignation = ID; stationContact = contact; stationTemperature = temperature; } class weatherStationSystem { vector <weatherStation> List; vector <weatherStation>::iterator ThroughTheList; string fileName;/////////////////////////////////// double fahrenheitToCelsius(double); public: weatherStationSystem(); void addWeatherStation(); void addTemperaturesPollen(); void showTemperatureReport(); void showTemperatureExtremes(); void showPollenReport(); void saveToFile(); string changeFileName(); void readFromFile(); }; double weatherStationSystem::fahrenheitToCelsius(double fahrenheitTemperature) { double celsiusTemperature = (5 * (fahrenheitTemperature - 32))/9; return celsiusTemperature; } void weatherStationSystem::addWeatherStation() { string ID; string contact; weatherStation Buffer; cout << "Enter Station Information. Stop to Quit" << endl; while(true){ cout << "Station Designation: "; getline(cin, ID); if(ID == "Stop") break; cout << "Contact Person: "; getline(cin, contact); Buffer.setDesignation(ID); Buffer.setContact(contact); List.push_back(Buffer); } } void weatherStationSystem::addTemperaturesPollen() { double highPollen; double lowPollen; double temperature; unsigned int K; weatherStation Buffer; cout << "Enter reported temperatures" << endl; for(K = 0; K < List.size(); K++){ cout << List[K].getDesignation() << endl; cout << List[K].getContact() << endl; cout << "Enter fahrenheit temperature: "; cin >> temperature; cout << "Enter high pollen count: "; cin >> highPollen; cout << "Enter low pollen count: "; cin >> lowPollen; Buffer.setTemperature(temperature); Buffer.setHighCount(highPollen); Buffer.setLowCount(lowPollen); List.push_back(Buffer); } } void weatherStationSystem::showTemperatureReport() { double MeanFahrenheitTemperature, MeanCelsiusTemperature; double Total = 0; unsigned int K; for(K = 0 ; K < List.size() ; K++) Total += List[K].getTemperature(); if(List.size() > 0) { MeanFahrenheitTemperature = Total / List.size(); MeanCelsiusTemperature = fahrenheitToCelsius(MeanFahrenheitTemperature); } else { cout << "The System Is Empty!" << endl; return; } cout << setprecision(3); cout.setf(ios::showpoint); cout << "\n\n\tNGS Daily Temperature Report" << endl; cout << "================================================" << endl; cout << "\t\t\t Fahrenheit\tCelsius" << endl; for(K = 0 ; K < List.size() ; K++) { cout << "------------------------------------------------" << endl; cout << List[K].getDesignation() << ":\t\t\t" << List[K].getTemperature() << "\t" << fahrenheitToCelsius(List[K].getTemperature()) << endl; } cout << "------------------------------------------------" << endl; cout << "Mean Temperature: \t" << MeanFahrenheitTemperature << "\t" << MeanCelsiusTemperature << endl; cout << "================================================\n\n" << endl; } void weatherStationSystem::showTemperatureExtremes() { double coldest, hottest; unsigned int K; coldest = hottest = List[0].getTemperature(); for(K = 1 ; K < List.size() ; K++) { if(List[K].getTemperature() < coldest) coldest = List[K].getTemperature(); if(List[K].getTemperature() > hottest) hottest = List[K].getTemperature(); } cout.setf(ios::showpoint); cout << setprecision(3); cout << "\n\n========NGS Temperature Data Report========" << endl; cout << "\t\t Fahrenheit\tCelsius" << endl; cout << "-------------------------------------------" << endl; cout << "Lowest Temperature:\t" << coldest << "\t" << fahrenheitToCelsius(coldest) << endl; cout << "-------------------------------------------" << endl; cout << "Highest Temperature:\t" << hottest << "\t" << fahrenheitToCelsius(hottest) << endl; cout << "-------------------------------------------" << endl; cout << "========End Temperature Data Report========\n" << endl; } void weatherStationSystem::showPollenReport() { unsigned int K; cout << setprecision(3); cout.setf(ios::showpoint); cout << "\n\n\tNGS Daily Pollen Report" << endl; cout << "================================================" << endl; for(K = 0 ; K < List.size() ; K++) { cout << List[K].getDesignation() << ":\t" << List[K].getMeanCount() << endl; } cout << "================================================\n\n" << endl; } string weatherStationSystem::changeFileName() { cout << "Enter new file name: "; getline(cin, fileName); cout << "The new file name is " << fileName; return fileName; } void weatherStationSystem::saveToFile() { fstream OutFile(fileName.c_str(), ios::out); for(ThroughTheList = List.begin() ; ThroughTheList < List.end() ; ThroughTheList++) OutFile << ThroughTheList -> getContact() << endl; OutFile << ThroughTheList -> getDesignation() << endl; OutFile << ThroughTheList -> getTemperature() << endl; OutFile << ThroughTheList -> getHighCount() << endl; OutFile << ThroughTheList -> getLowCount() << endl; OutFile.close(); } void weatherStationSystem::readFromFile() { fstream InFile(fileName.c_str(), ios::in); for(ThroughTheList = List.begin() ; ThroughTheList < List.end() ; ThroughTheList++) InFile << ThroughTheList -> getContact() << endl; InFile << ThroughTheList -> getDesignation() << endl; InFile << ThroughTheList -> getTemperature() << endl; InFile << ThroughTheList -> getHighCount() << endl; InFile << ThroughTheList -> getLowCount() << endl; } void menu()////////////////May be LNK2019 { cout << "Choices" << endl; cout << "Add Stations" << endl; cout << "Post Station Info" << endl; cout << "Daily Report" << endl; cout << "High-Low Report" << endl; cout << "Daily Pollen Count" << endl; cout << "Change File Name" << endl; cout << "Save To File" << endl; cout << "Read From File" << endl; cout << "Quit" << endl; } class weatherSystemUI : weatherStationSystem { weatherStationSystem weatherMatrix; public: weatherSystemUI(); }; weatherSystemUI::weatherSystemUI() { string command; while(true) { //Command loop menu(); cout << "Enter Command: "; getline(cin, command); if(command == "Quit") break; else if(command == "Enter Stations") weatherMatrix.addWeatherStation(); else if(command == "Enter Temperatures and Pollen Counts") weatherMatrix.addTemperaturesPollen(); else if(command == "Daily Report") weatherMatrix.showTemperatureReport(); else if(command == "High-Low Report") weatherMatrix.showTemperatureExtremes(); else if(command == "Daily Pollen Count") weatherMatrix.showPollenReport(); else if(command == "Change File Name") weatherMatrix.changeFileName(); else if(command == "Save To File") weatherMatrix.saveToFile(); else if(command == "Read From File") weatherMatrix.readFromFile(); } } int main() { weatherSystemUI BayArea; }
Comment