I have an array of objects:
Square sq[81];
I think it uses the default constructor to created each.
When I go though a for loop to initialize each, it calls the destructor for each Square object in the array.
for (int k=0; k<9; k++) {
for(int j=0; j<9; j++) {
sq[count++] = Square(k, j);
}
}
When Square(k, j) is called, is it deleting the object in sq[] and creating a new one?
No.
Square(k, j)creates a new temporary object and=copies it into the old one. The temporary object is then destroyed as it is not longer required and goes out of scope.BTW, you’re not actually initialising anything in the loop (other than that temporary, I mean); you’re just assigning, after-the-fact.