I'm using vscode and it doesn't compile it's Rectangle.cpp in the main file , when I used clion it compiled successfully when it was .h and did not work .cpp
I use gcc (MinGW.org GCC Build-2) 9.2.0
here is my all 3 files
main:
#include <bits/stdc++.h>
#include "Rectangle.h"
using namespace std;
int main(){
Rectangle r1(10.1,11.1);
cout<<r1.get_length()<<" "<<r1.get_width();
}
Rectangle.h:
#ifndef RECTANGLE_H
#define RECTANGLE_H
#pragma once
class Rectangle
{
public:
float get_length();
float get_width();
Rectangle();
Rectangle(float l , float w);
private:
float length;
float width;
};
#endif
Rectangle.cpp:
#include "Rectangle.h"
#include <iostream>
using namespace std;
Rectangle::Rectangle(){
}
Rectangle::Rectangle(float l,float w):length(l) , width(w){
}
float Rectangle::get_length(){
return length;
}
float Rectangle::get_width(){
return width;
}