To break it down, the first line of code bool *numberlist = new bool[size+1];
declare a dynamic bool arrays that have for size [size+1]. The code in the for loopnumberlist[i*j]=true;
means that the element i*j is true. In C++ array decayed to a pointer "more specificaly to a pointer to the first element"(meaning that each time we use an array in a expression, we are actually using a pointer) when we are accessing element of an array using brace operator ([]) we are doing 2 things. One pointer arithemtic(because an array is stored sequentially in memory) and Two dereference the pointer(to access the value that the pointer points to).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…