#include#include "Point2D.h" // Assumed package library int main() { Point2D p(20, 30); int x = p.getX(); // Get the x-coordinate of the point std::cout << "The x-coordinate of the point is: " << x << std::endl; return 0; }
#includeThis code creates a vector of Point2D objects and adds two points to it. Then, it loops through the vector and calls the getX() method on each Point2D object to get the x-coordinate of the point and prints it to the console.#include "Point2D.h" // Assumed package library int main() { std::vector points; points.push_back(Point2D(10, 20)); // Add point (10, 20) to vector points.push_back(Point2D(30, 40)); // Add point (30, 40) to vector for (int i = 0; i < points.size(); i++) { int x = points[i].getX(); // Get the x-coordinate of the point std::cout << "Point " << i+1 << ": (" << x << ", " << y << ")" << std::endl; } return 0; }