数组大小不正确由c ++

时间:2016-04-28 15:49:18

标签: c++ function

我有以下问题:

我在C ++中编写了一个函数,它应该计算给定数组的大小,但是 它不像预期的那样工作

我的代码:

#include <iostream>

using namespace std;

bool theArray[8];

void foo(bool boolArray[])
{
    cout << sizeof(boolArray) / sizeof(bool) << endl;
}

int main()
{
    cout << sizeof(theArray) / sizeof(bool) << endl;
    return 0;
}

0 个答案:

没有答案