connorvhennen / pointspointerspolymorphismandmemorymanagement Goto Github PK
View Code? Open in Web Editor NEWThis program creates four class, three that describe a point on a graph and one that is designed to store them, managing its memory automatically. The three graph point classes all describe its position, while ColorPoint2D describes its color as well, and WeightedPoint2D describes its weight as well. The color and weight classes are derived from the simplest point class, Point2D. The fourth class (Points) is designed to store pointers of type Point2D to objects of any of the three point classes in a vector. It automatically deconstructs after leaving the main function scope so there are no memory leaks. It also uses polymorphism to store objects of different types in the same vector.