x86_64 アーキテクチャでは、ポインターは 8 バイトです。sizeof(x)
8 を返す必要があるのは理にかなっています。 achar
は 1 バイトであり、5 バイトは array のサイズであることを理解していますz
。sizeof(z)
8 を返さない理由の背後にある直感は何ですか?
int* x = new int[10];
char z[5];
// Returns 8
std::cout << "This is the size of x: " << sizeof(x) << std::endl;
// Returns 5
std::cout << "This is the size of z: " << sizeof(z) << std::endl;