I have a strange problem. There is a vector of structures. With a temporary structure, I push_back to that vector of structures. But when I check the first member's cnt, I see that it became changed. Any idea? (Below code is a simplified version but a representative one)
struct Vector
{
  float *dim;
  Vector ()
  {
    dim = new float [3];
  }
};
struct Face
{
  float an_N, an_P;
  int P, N;
  Vector Af;
  float Ad;
  Vector cnt;
  float ifac;
  float mf;
};
std::vector <Face> face;
Face temp_face;
for (;;)
{
    temp_face.cnt.dim[0] = 0.f;
    temp_face.cnt.dim[1] = 0.f;
    temp_face.cnt.dim[2] = 0.f;
    for (int q=0; q<n_vtx_2D; ++q)
    {
        temp_face.cnt = temp_face.cnt + pt[vtx[q]] / n_vtx_2D;                
    }                 
    face.push_back(temp_face);
}
std::cout << face[0].cnt.dim[0] << std::endl;
Output
0.25
0
 
     
    