title: How to declare vector of object in c++?
body: <p>I receive the following error on declaring a vector of <code>Point</code> in the code shown (see reference to class template instantiation <code>std::vector&lt;Point,std::allocator&lt;Point&gt;&gt;</code> being compiled):</p>
  <blockquote>
  <p>Severity  Code    Description Project File    Line    Suppression State
  Error C2558   class 'Point': no copy constructor available or copy
  constructor is declared 'explicit'    AI assignment 1 C:\Program Files
  (x86)\Microsoft Visual
  Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\xmemory   671</p>
  </blockquote>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include&lt;vector&gt;
  using namespace std;
  
  int dx, dy, sx, sy;
  
  class Point
  {
  public:
      int x;
      int y;
      float g;
      float h;
  
      Point()
      {}
      Point(int s, int d)
      {
          x = s;
          y = d;
          h = pow(pow(x - dx, 2) + pow(y - dy, 2), 1 / 2);
  
      }
      Point(Point &amp;p)
      {
          x = p.x;
          y = p.y;
          g = p.g;
          h = p.h;
      }
  
      bool operator == (Point p)
      {
          if (p.x == x &amp;&amp; p.y == y)
              return true;
          else
              return false;
      }
  
  };
  
  class RoutePlaner
  {
      vector&lt;vector&lt;char&gt;&gt;grid;
      int mapsize;
      Point start;
      Point destination;
      int no_of_obstacles;
      vector&lt;Point&gt; obstacles;
  
      void generate_random_obstacles(int num)
      {
          for (int i = 0; i &lt; num; i++)
          {
              int k = rand() % mapsize;
              int j = rand() % mapsize;
              Point p(i, j);
              grid[j][k] = 'X';
              obstacles.push_back(p);
          }
      }
      
  public:
      RoutePlaner(int m, Point s, Point d, int no)
      {
          mapsize = m;
          start = s;
          destination = d;
          no_of_obstacles = no;
  
          vector&lt;char&gt; vec(mapsize, '.');
          for (int i = 0; i &lt; mapsize; i++)
          {
              grid.push_back(vec);
          }
  
          //Setting start and destination
          grid[start.x][start.y] = 'S';
          grid[destination.x][destination.y] = 'D';
  
          // setting obstacles
          generate_random_obstacles(no_of_obstacles);
  
  
      }
  };
  
  int main()
  {
  
  }
  </code></pre>
  <p>How should I declare a vector of class objects? How do I resolve the error?</p>