Creating an object in the loop

后端 未结 7 545
夕颜
夕颜 2021-01-14 00:56
 std::vector C(4);
 for(int i = 0; i < 1000;++i)
  for(int j = 0; j < 2000; ++j)
  {   
   C[0] = 1.0;
   C[1] = 1.0;
   C[2] = 1.0;
   C[3] = 1.         


        
相关标签:
7条回答
  • 2021-01-14 01:26

    The scope of the obj would be inside the loop, so you won't be able to use it once the loop(s) is(are) finished. This is in addition, to the object getting instantiated and then destroyed as many times as the loop(s) goes(go) through. In the end, nothing is accomplished except time is being wasted constructing and then destroying the object.

    0 讨论(0)
提交回复
热议问题