I'm trying to make a rectangle object and just do some simple commands. It has been a while since I've coded in c++ so I'm not sure what syntax errors I have? Any help would be appreciated

I'm getting the error:
request for member 'area' in 'c', which is of non-class type 'Rectangle*'
and the same error for perimeter as well

#ifndef RECTANGLE_H
#define RECTANGLE_H


class Rectangle
{
    private:
        float width;
        float length;
    public:
        Rectangle(float width, float length);
        ~Rectangle();
        float getWidth();
        float getLength();
        float area();
        float perimeter();
        float setWidth(float width);
        float setLength(float length);
        bool compareTo(Rectangle a,Rectangle b);
};

#endif // RECTANGLE_H
#include "Rectangle.h"
using namespace std;




int main()
    {
    Rectangle *a = new Rectangle(3,4);
    Rectangle *b = new Rectangle(3,4);
    a.area();
    b.perimeter();
    
    }

float width;
float length;

Rectangle::Rectangle(float l, float w)
    {
    setWidth(w);
    setLength(l);
    }

Rectangle::~Rectangle()
    {
    width = 0;
    length = 0;
    }


float Rectangle::getWidth()
    {
    return width;
    }

float Rectangle::getLength()
    {
    return length;
    }

float Rectangle::area()
    {
    return width * length;
    }

float Rectangle::perimeter()
    {
    return width + length;
    }

float Rectangle::setWidth(float W)
    {
    width = W;
    }

float Rectangle::setLength(float L)
    {
    length = L;
    }
bool Rectangle::compareTo(Rectangle a, Rectangle b){
    if(a.length == b.length && a.width == b.width)
        {
        return true;
        }
    else
        {
        return false;
        }

}

since a and b are pointers you need to use the -> operator not the . operator

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.