// 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; }
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;
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.
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.