1
0

13_square.cpp 391 B

123456789101112131415161718192021222324
  1. #include <iostream>
  2. using namespace std;
  3. class Square
  4. {
  5. int size;
  6. public:
  7. void set_size(int s);
  8. int get_size();
  9. int area() { return size * size; }
  10. };
  11. void Square::set_size(int s) { size = s; }
  12. int Square::get_size() { return size; }
  13. int main()
  14. {
  15. Square x;
  16. x.set_size(10);
  17. cout << "Area of square with side length " << x.get_size() << " is "
  18. << x.area() << endl;
  19. return 0;
  20. }