instance of a class?

I am new to C++. I am trying to create 5 instance object of class Test. I wonder if these two codes are the same. Thanks

1
2
3
4
5
6
7
8
Test testArray[5];
//which one is the correct way or what is the correct way?
for(i=0;i<5;i++)
{
   Test testArray;
}

They are different.

 
Test testarray[5];


The above piece is creating an array of 5 "Test".



This one below will create just 1 object per increase in the loop.

1
2
3
4
for(int i=0; i < 5; i++)
{
     Test testArray;
}
thanks
Topic archived. No new replies allowed.