// The Main Driver Program #include #include #include "Point.h" #include "Rectangle.h" using namespace std; struct Person{ string name; int age; }; int main() { Person p; // no pointer p.name = "Barb"; p.age = 21; Person *ptrPerson; // is a pointer ptrPerson = &p; ptrPerson->age = 30; ptrPerson->name = "Bob"; cout << p.name << endl; int i=5; // not a pointer int *ptr; // is a pointer ptr = &i; // assigned address of i to ptr cout << "ptr=" << *ptr << endl; ptr = new int; *ptr = 10; cout << "New ptr=" << *ptr << endl; delete ptr; // removes memory leak ptr = &i; // creates a memory leak cout << "After Del ptr=" << *ptr << endl; Point myFirstPoint; // no pointer Point *anPt = new Point(); // pointer Rectangle *newRect = new Rectangle(); // delete newRect, anPt; newRect->getArea(); cout << "myFirstPoint Default: " << myFirstPoint.getX() << endl; Point myOtherPoint(20); // no reference Point *newPt = new Point(20); // reference cout << "myOtherPoint Constructor 1: " << myOtherPoint.getX() << endl; Point myLastPoint(10, 20); Rectangle r1; // uses default constructor Rectangle r2(3,6); cout << "Area of r2= " << r2.getArea() << endl; Point myPts[] = {6,9,10}; cout << "myPts[1] x= " << myPts[1].getX() << endl; Point myNewPts[5]; myNewPts[0]=myFirstPoint; myNewPts[0].getX(); int x=10; int myInts[2]; myInts[0] = x; return 0; }