I have encountered the errors LNK2019
"unresolved external symbol "public: __thiscall Rect4::Rect4(double,double)" (??0Rect4@@QAE@NN@Z) referenced in function _main" and "unresolved external symbol "public: double __thiscall Rect4::calcArea(void)" (?calcArea@Rect4@@QAENXZ) referenced in function _main"
I was using Notepad++ to write/ edit the code and using Developer Command Prompt VS 2019 to compile the code. I also tried using the original Notepad to code too and reinstalled VS. But the same error popped up.
Here are the codes to look at. They are simple.
Header
class Rect3 {
public:
Rect3(double , double);
double calcArea();
private:
double w;
double h;
};
Implementation
#include "Rect3.h"
Rect3 :: Rect3(double _w,double _h) {
w = _w; h = _h;
}
Rect3 :: double calcArea() {
return w*h;
}
Driver
#include <iostream>
#include "Rect3.h"
using namespace std;
void main() {
Rect3 rect(4,5);
cout << rect.calcArea() << endl;
}
Could anyone know/ help solve the issue? Thanks a lot.