数组初始化

来源:互联网 发布:php array indexof 编辑:程序博客网 时间:2024/05/28 04:54
    void insetStructFunc() {        struct Inset {            int value;            Inset() :value(0) {};        };        Inset in_array[10];        for (int i = 0; i < 10; i++) {            cout << in_array[i].value << endl;        }        int a[10];        for (int i = 0; i < 10; i++) {            cout << a[i] << endl;        }    }

in_array 在定义的时候会调用默认构造函数将i进行初始化。

a[10] 打印出的是乱码,即内存原来存储的内容

原创粉丝点击