Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
v 它是一个整数数组,a 它是一个整数:
#include <iostream> using namespace std; int main() { int v[10], a; cout << v[a] << endl; cout << a[v] << endl; return 0; }
返回相同的值:0 0
这是为什么 ?
因为索引器语法的意思是“数组开头表示的地址中的值加上一个偏移量”。或者,换一种说法:
v[a] == *(v + a) == *(a + v) == a[v]