Добавил:
vvrstcnho
Рад, если кому-то помог
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторные работы С++ (для ИВТ) / Готовые лабы С++ / Лаба4 / Laba 4 (12)
.cpp#include <iostream>
#include <locale>
using namespace std;
class point {
int *x, *y, *z;
public:
point(int c1 = 0, int c2 = 0, int c3 = 0) {
x = new int(c1);
y = new int(c2);
z = new int(c3);
}
~point() {
delete x;
delete y;
delete z;
}
bool operator==(const point& other) const {
return *x == *other.x && *y == *other.y && *z == *other.z;
}
void set(int c1, int c2, int c3) {
*x = c1;
*y = c2;
*z = c3;
}
void print() const {
cout << "(" << *x << ", " << *y << ", " << *z << ")" << endl;
}
};
int main() {
setlocale(LC_ALL, "ru_RU.UTF-8");
point p1(1, 2, 3);
point p2(1, 2, 3);
point p3(4, 5, 6);
cout << "p1 = "; p1.print();
cout << "p2 = "; p2.print();
cout << "p3 = "; p3.print();
cout << "p1 == p2: " << (p1 == p2) << endl;
cout << "p1 == p3: " << (p1 == p3) << endl;
return 0;
}
Соседние файлы в папке Лаба4
