嗨,我有以下 c++ 代码,我想在 main 中调用函数,以下是我的代码:
#include <iostream>
#include <numeric>
int main()
{
using namespace std;
readData();
int sumA = accumulate(A, A + sizeof(A) / sizeof(int), 0);
int sumB = accumulate(B, B + sizeof(B) / sizeof(int), 0);
cout << ((sumA > sumB) ? "Array A Greater Than Array B\n" : "Array B Greater Than Array A\n");
return 0;
}
void readData()
{
int A[] = { 1, 1, 8};
int B[] = { 2, 2, 2};
}
我在 cli 上有以下错误:
test.cpp:3:7: error: storage size of ‘B’ isn’t known
test.cpp:4:7: error: storage size of ‘A’ isn’t known
我在哪里错了?谢谢