jeudi 7 octobre 2021

C++: What is the difference between new int[3] and new int[3]()

What's the difference between the below 2 codes in main() function? Both are filled with 0s. I expect array q to be filled with 0s since it's value-init. However array p is also filled with 0s.

int main() {
    int *p = new int[3];
    int *q = new int[3]();
}

Aucun commentaire:

Enregistrer un commentaire