Hey guys just wondering wether one of you guys could help me with my program and why it's not reading my .hpp file.
RECT.cpp
Rect.hppCode:#include "Rect.hpp" Rectangle::Rectangle(int top, int left, int bottom, int right) { itsTop = top; itsLeft = left; itsBottom = bottom; itsRight = right; itsUpperLeft.SetX(left); itsUpperLeft.SetY(top); itsLowerLeft.SetX(right); itsLowerLeft.SetY(top); itsUpperRight.SetX(left); itsUpperRight.SetY(bottom); itsLowerRight.SetX(left); itsLowerRight.SetY(bottom); } int Rectangle::GetArea() const { int Width = itsRigth - itsLeft; int Height = itsTop - itsBottom; return (width * Height); } int main() { Rectangle MyRectangle.GetArea(); cout << "Area: " << Area << "\n"; cout "Upper Left X Coordinate: "; cout << MyRectangle.GetUpperLeft().GetX(); return 0;
If you can help me thanks a lot, and i'm using Dev-C++.Code:#include <iostream> class Point // hold x, y coordinates { // no constructor, use default public: void SetX(int x) { itsX = x; } void SetY(int y) { itsY = y; } int GetX()const { return itsX;} int GetY()const { return itsY;} private: int itsX; int itsY; }; // end of Point Class declaration Class Rectangle { public: Rectangle (int top, int left, int bottom, int right); ~Rectangle () {} int GetTop() const { return itsTop; } int GetLeft() const { return itsLeft; } int GetBottom() const { return itsBottom; } int GetRight() const { return itsRight; } Point GetUpperLeft() const { return itsUpperLeft; } Point GetLowerLeft() const { return itsLowerLeft; } Point GetUpperRight() const { return itsUpperRight; } Point GetLowerRight() const { return itsLowerRight; } void SetUpperLeft(Point Location) {itsUpperLeft = Location;} void SetLowerLeft(Point Location) {itsLowerLeft = Location;} void SetUpperRight(Point Location) {itsUpperRight = Location;} void SetLowerRight(Point Location) {itsLowerRightt = Location;} void SetTop(int top) { itsTop = top; } void SetLeft(int left) { itsLeft = left; } void SetBottom(int bottom) { itsBottom = nottom; } void SetRight(int right) { itsRight = right; } int GetArea() const; private: Point itsUpperLeft; Point itsUpperRight; Point itsLowerLeft; Point itsLowerRight; int itsTop; int itsLeft; int itsBottom; int itsRight; };



1Likes
LinkBack URL
About LinkBacks



