Calling function in custom class using pointer

hello all, right now I have code


#include <iostream>

using namespace std;

class Rectangle
{
private:
double width;
double length;
public:
double area()
{
return width*length;
}
double perimeter()
{
return 2*width+2*length;
}
void setLength(double L)
{
length = L;
}
void setWidth(double W)
{
width = W;
}
};

int main()
{
Rectangle R;
R.setLength(5);
R.setWidth(4);
cout << R.area() << endl;
cout << R.perimeter() << endl;

Rectangle* pR = new Rectangle;
pR -> setLength(10);
pR -> setWidth(5);
cout << pR.area() << endl; // Call the area() function using pR
cout << pR.perimeter << endl; // Call the perimeter() function using pR

delete pR;
}

it gives error

any idea?
I have an idea: copy and paste the exact errors you are getting, and don't mark topics solved unless they are solved ;)
Topic archived. No new replies allowed.