Files
ZUT-notatki/uczelnia/2_semestr/programowanie/laby/kolokwium1.cpp
2026-03-31 16:57:45 +02:00

30 lines
657 B
C++

#include <iostream>
using namespace std;
class Pole_Szymon_Prusiewicz {
public:
int x, y;
Pole_Szymon_Prusiewicz(int x, int y) : x(x), y(y) {
cout << x << ' ' << y << endl;
}
~Pole_Szymon_Prusiewicz() { cout << "koniec zycia" << endl; }
void oblicz_pole() { cout << "Pole wynosi: " << x * y << endl; }
Pole_Szymon_Prusiewicz &operator=(const Pole_Szymon_Prusiewicz &inne_pole) {
cout << "Przypisanie" << endl;
if (this != &inne_pole) {
x = inne_pole.x;
y = inne_pole.y;
}
return *this;
}
};
int main() {
Pole_Szymon_Prusiewicz p1(1, 2);
Pole_Szymon_Prusiewicz p2 = p1;
p1.oblicz_pole();
return 0;
}