title: Pushing back elements in c++ std::vector, they lose information
body: <p>I'm working on a pre-existing code and checking if it works.</p>
  
  <p>With my greatest surprise, these basic classes are giving me troubles</p>
  
  <pre><code>typedef int Id;
  typedef int BcId;
  
  //!  This class gives some common methods to all mesh objects.
  class Identifier{
  public:
  
      static const UInt NVAL;
  
      Identifier(UInt id):id_(id),bcId_(NVAL){}
      Identifier(UInt id, UInt bcId):id_(id),bcId_(bcId){}
  
      bool unassignedId()const {return id_==NVAL;}
      bool unassignedBc()const {return bcId_==NVAL;}
  
      Id id() const {return id_;}
      BcId bcId() const {return bcId_;}
      Id getId() const {return id_;}
  
  
      protected:
      Id id_;
      BcId bcId_;
  };
  
  
  //!  This class implements a 3D point, the default is z=0 =&gt; 2D point
  class Point: public Identifier{
  public:
  
      static const UInt ndim = 3;
  
      Point(): Identifier(NVAL, NVAL){coord_.resize(3);};
      Point(Real x, Real y, Real z=0):Identifier(NVAL, NVAL)
          {coord_.resize(3);coord_[0]=x; coord_[1]=y; coord_[2]=x;}
      Point(Id id, BcId bcId, Real x, Real y, Real z=0):Identifier(id, bcId)
          {coord_.resize(3);coord_[0]=x; coord_[1]=y; coord_[2]=z;}
      void print(std::ostream &amp; out) const;
      Real operator[](UInt i) const {return coord_[i];}
  
      private:
      std::vector&lt;Real&gt; coord_;
  
  };
  
  void Point::print(std::ostream &amp; out) const
  {
  out&lt;&lt;"Point -"&lt;&lt; id_ &lt;&lt;"- "&lt;&lt;"("&lt;&lt;coord_[0]&lt;&lt;","&lt;&lt;coord_[1]&lt;&lt;","&lt;&lt;coord_[2]&lt;&lt;")"&lt;&lt;std::endl&lt;&lt;"------"&lt;&lt;std::endl;
  }
  </code></pre>
  
  <p>Now with the simplest test:</p>
  
  <pre><code>int main()
  {
      Point a(1,1,0,0);
      Point b(2,2,0,1);
      Point c(3,3,1,0);
  
      a.print(std::cout);
      b.print(std::cout);
      c.print(std::cout);
  
      std::cout&lt;&lt;b.getId()&lt;&lt;std::endl;
      b.print(std::cout); 
  
      std::vector&lt;Point&gt; points;
      points.resize(3);
      points.push_back(c);
      points.push_back(b);
      points.push_back(a);
  
  
      std::cout&lt;&lt;"The points are"&lt;&lt;std::endl;
      for (int i=0; i&lt;3; ++i)
          points[i].print(std::cout);
      std::cout&lt;&lt;std::endl;
  
  }
  </code></pre>
  
  <p>I get the output:</p>
  
  <pre><code>Point -1- (0,0,0)
  ------
  Point -2- (0,1,0)
  ------
  Point -3- (1,0,0)
  ------
  2
  Point -2- (0,1,0)
  ------
  The points are
  Point -2147483647- (0,0,0)
  ------
  Point -2147483647- (0,0,0)
  ------
  Point -2147483647- (0,0,0)
  </code></pre>