Here is the code that I have so far:
#include <iostream>
using namespace std;
class Rectangle
{
private:
double width, height;
public:
Rectangle();
double Set(double x, double y);
double getArea();
double getPerimeter();
};
Rectangle::Rectangle()
{
width = 1;
height = 1;
}
double Rectangle::Set(double x, double y)
{
width = x;
height = y;
}
double Rectangle::getArea()
{
double area = height * width;
return area;
}
double Rectangle::getPerimeter()
{
double perimeter = (width * 2) + (height * 2);
return perimeter;
}
int main()
{
double width, height;
cout << "Enter the width and height of a rectangle:";
cin >> width >> height;
cout << "The area is " << Rectangle::getArea << " and the perimeter is " << Rectangle::getPerimeter << endl;
}
When running this code I get the error : "'Rectangle::getArea': non-standard syntax; use '&' to create a pointer to member" I get the same error about the Rectangle::getPerimeter I am not sure what the problem is, I am new to making classes in C++ obviously, so I am having some trouble. Any suggestions?