C++數組的引用

int test12()
{
    int a[10] = { 0 };
    int *q = a;
    int (&p)[10] = a;//數組的引用
    cout << "q[1]=" << q[1] << endl;
    cout << "p[1]=" << p[1] << endl;
    cout << "sizeof(a)=" << sizeof(a)<<endl;
    cout << "sizeof(&a)=" << sizeof(&a)<<endl;
    cout << "sizeof(q)=" << sizeof(q)<<endl;
    cout << "sizeof(p)=" << sizeof(p)<<endl;
    return 0;

}


int main()
{
	test12();

}

輸出:

q[1]=0
p[1]=0
sizeof(a)=40
sizeof(&a)=8
sizeof(q)=8
sizeof(p)=40

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章