error LNK2019 and fatal error LNK1120

I am a college student and this is one of my project for my C++ class,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <iomanip>
#include <iostream> 
#include <vector>
#include <string> 
#include <cctype>
using namespace std;

void Menu()
{
	cout<<"Choices........................................................................" << endl
		<<"-------------------------------------------------------------------------------"<<endl
		<<"\tPost......allows the user to post temperatures" << endl
		<<"\tHighLow...displays the report of high and low temperatures" << endl
		<<"\tDaily.....display the daily report" << endl
		<<"\tQuit......exits the program"<<endl
		<<"-------------------------------------------------------------------------------\n";
}

class WeatherStation 
{
	string StationDesignation;  
	double Temperature;
public:
	WeatherStation();
 	void SetDesignation(string ID)    { StationDesignation = ID; }
	void SetTemperature(double Degree)  {Temperature = Degree; }
	string GetDesignation()    { return StationDesignation; }
	double GetTemperature()  { return Temperature; }
};

WeatherStation::WeatherStation()
{
	StationDesignation = "";
	Temperature = 0.0;
}

class WeatherStationList
{
	vector<WeatherStation> List;
public:
	WeatherStationList();
	void SetUp();
	void PostTemperature();
	void HighLow();
	void Daily();
};

void WeatherStationList::SetUp()
{
	WeatherStation Loc;

	Loc.SetDesignation("Tciitcgatc"); 
	List.push_back(Loc);

	Loc.SetDesignation("Redwood Haven");
	List.push_back(Loc);
	
	Loc.SetDesignation("Barrier Mts.");
	List.push_back(Loc);
	
	Loc.SetDesignation("Nina`s Folly");
	List.push_back(Loc);
	
	Loc.SetDesignation("Sooly`s Hill");
	List.push_back(Loc);
	
	Loc.SetDesignation("Twin Cones Park");
	List.push_back(Loc);
}

void WeatherStationList::PostTemperature()
{
	double Temp;
	for(int i = 0 ; i < 6 ; ++i)  
	{
		cout << "\nWeather Station: " << List[i].GetDesignation() << endl;  
		cout << "Temperature: ";  
		cin >> Temp;
		List[i].SetTemperature(Temp);
		cout << endl;
	}  
	cout << endl;
	cin.ignore(100, '\n');
}

void WeatherStationList::HighLow()
{
	double low = List[0].GetTemperature();
	for(int i = 1 ; i < 6 ; ++i)
		low = List[i].GetTemperature() > low ? low:List[i].GetTemperature();
	double high = List[0].GetTemperature();
	for(int i = 1 ; i < 6 ; ++i)
		high = List[i].GetTemperature() < high ? high : List[i].GetTemperature();
	cout << "\n\n===============================Temperature Report=============================="<<endl
		 << "\n\t\t\tFahrenheit\tCelsius" << endl
		 << "-------------------------------------------------------------------------------"
		 << setprecision(4)
		 << "\nLowest Temperature =\t\t" << low << "\t" << (low-32)*5/9 << endl
		 << "-------------------------------------------------------------------------------"
		 << "\nHighest Temperature =\t\t" << high << "\t" << (high-32)*5/9 << endl << endl
		 << "-------------------------------------------------------------------------------\n\n";
}

void WeatherStationList::Daily()
{
	double sum = 0, mean = 0;
	for (int i = 0 ; i < 6 ; ++i)	sum += List[i].GetTemperature();
	mean = sum/List.size();
	cout << "\n\n===============================Temperature Report=============================="
		 << "\n\n\t\t\tFahrenheit\tCelsius" << endl
		 << "-------------------------------------------------------------------------------"
		 << setprecision(4)
		 << "\nMean Temperature =\t" << mean << "\t\t" << (mean-32)*5/9<<endl
		 << "-------------------------------------------------------------------------------\n"
		 << "Raw Data:\n\n";
	for (int i = 0 ; i < 6 ; ++i)
		cout << List[i].GetDesignation() << "\t\t" << List[i].GetTemperature()<<"\t\t"<<(List[i].GetTemperature()-32)*5/9<<endl;
	cout << "-------------------------------------------------------------------------------\n\n\n";
}

int main()
{
	WeatherStationList List;
	List.SetUp();
	string Command = "";
	while (Command != "quit")
	{
		Menu();
		cout << "Command: ";
		getline (cin, Command);
		int CommandLength = Command.size();
		for (int i = 0 ; i < CommandLength ; i++)
			Command[i] = tolower(Command[i]);
		if (Command == "post")
			List.PostTemperature();
		else if (Command == "highLow")
			List.HighLow();
		else if (Command == "daily")
			List.Daily ();
	}
	cin.ignore(100, '\n');
	return 0;
}


It`s just a raw draft, but when I try to run it, it says:

1>------ Build started: Project: Project_03, Configuration: Debug Win32 ------
1>Project_03.obj : error LNK2019: unresolved external symbol "public: __thiscall WeatherStationList::WeatherStationList(void)" (??0WeatherStationList@@QAE@XZ) referenced in function _main
1>E:\Documents\US\College\Foothill College\CIS 15A\Projects\Project_03\Debug\Project_03.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Anyone has any idea on that?
I am really confused...

Thank you very much!!
Last edited on
On line 41 you have that constructor WeatherStationList(), but you didn't implement it. Just remove it
Hi there,

I think this is the problem:

1
2
3
//line 40
public:
	WeatherStationList();


You have declared a constructor, but you have not actually created the method. When you create the object, it tries to run the constructor, which it now thinks you have defined, but it can't find it.

Either comment out that line and use the default constructor, or actually implement the constructor method.

Hope that helps.

All the best,
NwN
Thank you coder777 and NwN, that works!
Topic archived. No new replies allowed.