#include // allows use of cin and cout #include "Point.h"; #include "ColorPoint.h"; using namespace std; int main(){ string test = "hello"; Point p(0,0); // calls the Point constructor - don't use constructor directly! cout << p.toString() << endl; p.translate(1,5); cout << p.toString() << endl; Point *q = new Point(5,7); // allocated a reference to a point using new cout << q->toString() << endl; q->translate(3,-1); cout << q->toString() << endl; // the following is equivalent to "->" but uglier cout << (*q).toString() << " in ugly way" << endl; cout << endl << "Starting color points" << endl; ColorPoint cp(1,2,"red"); // again avoid direct use of constructor cout << cp.toString() << endl; // what happens when a colorpoint is assigned to a point variable p = cp; // bad news, it is truncated to a point! cout << p.toString() << endl; p.translate(1,2); // uses point code, not colorpoint cout << p.toString() << endl; // Correct way is to use pointers and "new". ColorPoint *cq = new ColorPoint(3,4,"red"); cout << cq->toString() << endl; q = cq; q->translate(2,2); cout << q->toString() << endl; return 0; }