Files
lab-cpp-classes-objects/src/task03/main.cpp
T
2026-07-21 20:11:42 +02:00

4 lines
435 B
C++

#include <iostream>
class Rectangle { public: Rectangle(int width, int height) : width_{width}, height_{height} {} int area() const { return width_ * height_; } void scale(int factor) { width_ *= factor; height_ *= factor; } private: int width_; int height_; };
int main() { Rectangle rectangle{6, 4}; const int before = rectangle.area(); rectangle.scale(2); std::cout << "area=" << before << " scaled=" << rectangle.area() << '\n'; }