Hello, I'm a bit new to c++ and trying to practice the object-oriented part of it by converting my java programs into c++. I believe I understand the concepts of a header file and declaring the functions in the .cpp files. I keep getting this "Undefined reference to NamedStorm::NamedStorm()" error. I researched and asked in many places and never got a clear answer. Can you guys help?
It looks like that file NamedStorm.cpp was not included in the project. That is when the linker processed the object file with main it did not have access to the object file of NamedStorm.cpp
NamedStorm.cpp
line 14: no variable named "windSpeed" (did you mean "maxWindSpeed"?)
line 21: missing semicolon
line 55: function header does not match declaration in header file
#include <iostream>
#include <string>
#include "NamedStorm.h"
usingnamespace std;
NamedStorm storm[2];
int main(){
usingnamespace std;
storm[0] = NamedStorm("Chris", 70.0, "T.S.", 990.0);
cout << "Storms this season: " << storm[0].getStormCount() << "\n";
cout << storm[0].getName() << " has a wind speed of " << storm[0].getWindSpeed() << ".\n";
return 0;
}
Output is:
Storms this season: 3
Chris has a wind speed of 70.
You'll notice that the number of storms this season is wrong. You'll need to add that destructor in and decrement stormCount. (It happened because of the temporary created on line 12 of main().)
Im relieved that its not my fault, but the compiler. VS and C::B have been acting very strange lately. Thanks for the help, I'll just reinstalled them both