Advertisement
karlicoss

problem, LSP?

Jun 29th, 2011
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. class Rectangle
  2. {
  3. public:
  4.     Rectangle(int h_ = 0, int w_ = 0): height(h_), width(w_)
  5.     {
  6.     }
  7.     void set_size(int h, int w)
  8.     {
  9.         do_set_size(h, w);
  10.     }
  11. protected:
  12.     void do_set_size(int h, int w)
  13.     {
  14.         height = h;
  15.         width = w;
  16.     }
  17. private:
  18.     int height, width;
  19. };
  20.  
  21. class Square: protected Rectangle
  22. {
  23. public:
  24.     Square(int h_): Rectangle(h_, h_)
  25.     {
  26.     }
  27.     void set_size(int h)
  28.     {
  29.         do_set_size(h, h);
  30.     }
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement