Declare an array of objects using a for loop c++

后端 未结 3 1471
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 17:53

Okay. So I have declared an array of objects, and I have manually defined them using this code:

Object* objects[] =
{
    new Object(/*constructor parameters         


        
3条回答
  •  醉梦人生
    2020-12-30 18:51

    Object* objects[20];
    
    for(int i=0; i<20; /*number of objects*/ i++)
    {
        objects[i] = new Object(/*constructor parameters*/);
    }
    

提交回复
热议问题