Ответ:
#include
#include
class Point {
protected:
double* arr; //массив с координатами по осям
size_t size; //размерность пространства
public:
Point(size_t s) : size(s) {
arr = new double[s];
}
~Point() {
delete[] arr;
}
virtual void print() = 0; //вывод координат
};
class Point2D : public Point {
public:
Point2D(double x,double y) : Point(2) {
arr[0] = x; arr[1] = y;
}
void print() override {
std::cout
}
};
class Point3D : public Point {
public:
Point3D(double x, double y, double z) : Point(3) {
arr[0] = x; arr[1] = y; arr[2] = z;
}
void print() override {
std::cout
}
};
int main(int argc, char* argv[]) {
Point* p1 = new Point2D(1.5, 4.8);
Point* p2 = new Point3D(1.0, 10.2, 3.3);
p1->print();
p2->print();
delete p1;
delete p2;
return 0;
}