title: how to partition a square into arbitrary number of squares?
body: <p>I was wondering if there is way to split the area of square into specified number of smaller squares.
  and assume the primary square has fixed size of 80*80.</p>
  
  <pre><code>typedef std::pair&lt;int, int&gt; Point;
  
  class Square
  {
  Point left_down = {0, 0};
  Point up_right;
  public:
  int lowerB(){ return left_down.first; }
  int upperB() { return up_right.first; };
  
  Square(){}
  Square(int size) :up_right({size, size}) {};
  Square(Point p1, Point p2): left_down(p1), up_right(p2) 
  {}
  
  static int number_of_squares;
  };
  int Square::number_of_squares = 1;
  </code></pre>
  
  <p>and i derived a class from Square to form the sub-squares:</p>
  
  <pre><code>class Sub_sqr: public Square
  {
  Point xy1;
  Point xy2;
  
  int S_indx; // an identifier
  
  public:
  Sub_sqr() { number_of_squares++; }
  int indx() { return S_indx; }
  };
  </code></pre>
  
  <p>I've tried the above algorithm, is it correct? the number of instances we make the number of squares we have.
  for example if we want to extract 256 not overlapping sub-squares out of square with size 80 * 80 or whatever, we should have 256 instances of sub_sqr class.</p>
  
  <p>My final goal to make grid inside the square by partitioning it into equal size sub-squares.</p>
  
  <p><a href="https://i.stack.imgur.com/hy8jF.jpg" rel="nofollow noreferrer">Square partitioning</a></p>
  
  <p>Any comments or help will be greatly appreciated.</p>
  
  <p>Regards</p>