feat: implement CPP05 C++20 card
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
#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'; }
|
||||
Reference in New Issue
Block a user