It seems that you already had the functions getLength() and getWidth() defined in your class. You can actually delete the duplicate functions defined outside of class scope, so these functions you should completely remove from your code--
float Rectangle::getWidth()
{
return W;//Is this right?
}
float Rectangle::getLength()
{
return L;
}
-- because your class already has them defined and double-defining is illegal.
My apologies for not catching this the first time. I immediately assumed you followed the header/source file format for classes within one file. What I mean is I assumed this--
// file data.h
struct data{
void p();
}
// file data.cpp
#include <iostream>
using std::cout;
using std::endl;
void data::p(){
cout << "data:p()" << endl;
}
-where the class functions are not yet defined until later in the same file or in a different file. That is the usual format for classes, but you don't really have to follow it.
Alright, another thing. About rectangles. What is needed to define the perimeter and area of the rectangle? A rectangle is nothing more than a shape that is surrounded with 4 lines enclosing the shape with four 90 degree angles and each set of parallel sides have the same length as its parallel side (but it isn't restricted to not being the same length of its perpendicular side, so a rectangle can be a square... but a square cant be a rectangle). You only need 1 length and 1 width to determine the perimeter …