Errors:
22 'Rectangle::Rectangle()' and 'Rectangle::Rectangle()' cannot be
28 'Rectangle::~Rectangle()' and 'Rectangle::~Rectangle()' cannot be
44 parse error at end of input
If I take out the constructor and destructor deffinition it works... But I want them there, and I want to know why it doesn't like that.
As for the input error I have no clue what I did wrong =/
thanks
Code:#include <iostream> using namespace std; class Rectangle { public: Rectangle(); ~Rectangle(); void SetLength(int length) { this->itsLength = length;} int GetLength() const { return this->itsLength; } void SetWidth(int width) { itsWidth = width;} int GetWidth() const { return itsWidth; } private: int itsLength; int itsWidth; }; Rectangle::Rectangle() { itsWidth = 5; itsLength = 10; } Rectangle::~Rectangle() {} int main(int argc, char *argv[]) { Rectangle theRect; cout << "theRect is " << theRect.GetLength() << " feet long.\n"; cout << "theRect is " << theRect.GetWidth() << " feet wide.\n"; theRect.SetLength(20); theRect.SetWidth(10); cout << "theRect is " << theRect.GetLength() << " feet long.\n"; cout << "theRect is " << theRect.GetWidth() << " feet wide.\n"; return 0; }