Errors with creating header files

In part 3 of the C++ course in the creating objects video, I’m having trouble with creating the class in visual studio code.

main.cpp:
#include “rectangle.hpp”
#include
using namespace std;

int main() {
rectangle rectangle;
rectangle.width = 10;
rectangle.height = 20;
rectangle.draw();
cout << rectangle.getArea();
return 0;
}

rectangle.cpp:
#include “rectangle.hpp”
#include
using namespace std;

void rectangle::draw() {
cout << “Drawing a rectangle” << endl;
cout << "Dimensions: " << width << ", " << height << endl;
}

int rectangle::getArea() {
return width * height;
}

rectangle.hpp:
#ifndef RECTANGLE_H
#define RECTANGLE_H

class rectangle {
public:
int width;
int height;
void draw();
int getArea();
};

#endif

This is my code and this is the error that comes up when I run it.

C:/msys64/mingw64/bin/…/lib/gcc/x86_64-w64-mingw32/12.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe: C:\Users-------\AppData\Local\Temp\cck5lW42.o:main.cpp:(.text+0x23): undefined reference to rectangle::draw()' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\--------\AppData\Local\Temp\cck5lW42.o:main.cpp:(.text+0x2f): undefined reference to rectangle::getArea()’
collect2.exe: error: ld returned 1 exit status

What I think is happening is that I am unable to compile all of the files together at once. Does anyone have any fixes?

Change your class name from rectangle from Rectangle. When creating object it cannot find the identifier for your type rectangle. It is like declaring int int;

Also,

Change the second line to #include <iostream> if it is not an error while copying.

Hello,
I have same problem. Did you solved it? if you did, please can you help me?

I have posted the solution. If it is something else then ask a new question or post the new error after trying the solution (if any).

I also got the same issue while running code using VS code. So the code runner is not providing the implementation class while compiling and so its not linking it. To solve this error you manually run using the below command from terminal instead of run icon :
g++ -o Main main.cpp rectangle.cpp && Main.exe
This will compile and show the output on terminal.