Can some one tell me what LOCATION is?

// begin rectangle.hpp
#include <iostream>
using namespace std;

class Point // holds x, y coords
{
// 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); // constructor
~Rectangle() { } // destructor

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) { itsLowerRight = Location; }

void SetTop(int top) { itsTop = top; }
void SetLeft(int left) { itsLeft = left; }
void SetBottom(int bottom) { itsBottom = bottom; }
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;
};
// end Rectangle.hpp


Can someone tell me what in the heck Location is in this .h file? I can understand the whole program when it's laid out...calling a function from another class' function but I have no idea what Location is? is it a data type? or it a variable? is it a built in function of c++(which i searched for and didn't find). I get classes pretty much, need to drill it in my head with some of my own written programs but this "classes with other classes as member data" through me for a loop. Any insight would be greatly appreciated. Below is the .cpp file that accompanies this header. Thanks, Dan


// begin Rectangle.cpp
#include <iostream>
#include "listing6-8.h"
using namespace std;

Rectangle::Rectangle(int top, int left, int bottom, int right)
{
itsTop = top;
itsLeft = left;
itsBottom = bottom;
itsRight = right;

itsUpperLeft.SetX(left);
itsUpperLeft.SetY(top);

itsUpperRight.SetX(right);
itsUpperRight.SetY(top);

itsLowerLeft.SetX(left);
itsLowerLeft.SetY(bottom);

itsLowerRight.SetX(right);
itsLowerRight.SetY(bottom);
}

// computer area of rectangle by finding sides,
// establish width and height and then multiply

int Rectangle::GetArea() const
{
int Width = itsRight - itsLeft;
int Height = itsTop - itsBottom;
return (Width * Height);
}

int main()
{
// initialize a local rectangle veriable/object
Rectangle MyRectangle(100, 20, 50, 80);

int Area = MyRectangle.GetArea();

cout << "Area: " << Area << endl;
cout << "Upper left X coodinate: ";
cout << MyRectangle.GetUpperLeft().GetX() << endl; // this is the part!!!

return 0;
}


Thanks again,

Dan
It could be a keyword specified with the #define tag, but given that it most likely represents the current location of something, it's probably a variable. There might be something in "listing6-8.h" to explain it, but you would have to post it.
Last edited on
listing 6-8 is the header file..that what I have posted is the whole code of the project. Sorry for the confusion and thanks for the reply.

Dan
The only reference to something called location that I can see in all that are function parameter names

1
2
3
4
void SetUpperLeft(Point Location) { itsUpperLeft = Location; }
void SetLowerLeft(Point Location) { itsLowerLeft = Location; }
void setUpperRight(Point Location) { itsUpperRight = Location; }
void setLowerRight(Point Location) { itsLowerRight = Location; }
yes exactly...damn I don't know I just found out I have some traumatic brain injury from my youth and I don't think I have the cognitive ability to take this in now. Although I think the author used a messy problem to introduce classes with other classes as member data....sure would have been an easier way to introduce this topic LOL..but thanks I will go back and look at the code closely and try to replicate a program on my own using this topic.
Topic archived. No new replies allowed.