为什么sizeof()我的双数组[4]只有4?

use*_*484 0 c++ arrays sizeof

我正在尝试编写一个遍历数组中所有元素的循环.我在这里学到了这个概念.我的执行面临一些困难.我一直在尝试调试,我已经编写了以下函数作为调试过程的一部分.以下是我的代码:

#include <iostream>
using namespace std;

struct Vmul {
    double c[4][4];
};
double Vmulti(double a[4], double d[4]) {
    cout << sizeof(a) << endl;
    cout << sizeof(a[0]) << endl;
    cout << sizeof(a)/ sizeof(a[0]) << endl;
    return 0;
}
int main()
{
    double r[4] = { 1,2,3,4 };
    double q[4] = { 1,2,3,4 };
    Vmulti(r, q);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

4
8
0
Press any key to continue . . .
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚为什么sizeof(a)只返回4?不应该是8*4吗?为什么sizeof不给我大小而是给我数组中的元素数量?

Eri*_*ich 7

来自编译器的错误消息可以很长的路要走:

test.cpp:8:23: warning: sizeof on array function parameter will return size of 'double *' instead of 'double [4]'
      [-Wsizeof-array-argument]
        cout << sizeof(a) << endl;
                      ^
test.cpp:7:22: note: declared here
double Vmulti(double a[4], double d[4]) {
Run Code Online (Sandbox Code Playgroud)