use of undeclared identifier 'cout'; did you mean 'std::cout'?
改为
std::cout << &array[0][0] << " " << &array[0][1] << " " << &array[0][2] << std::endl;
std::cout << &array[1][0] << " " << &array[1][1] << " " << &array[1][2] << std::endl;
为什么要加std::
在C++中,cout 是在 std 命名空间中定义的标准输出流。因此,为了告诉编译器将 cout 查找到 std 命名空间中,我们需要加上 std:: 前缀。这样做可以帮助编译器正确地识别和定位 cout。
我不可以用一个头文件代替它吗
你可以通过包含头文件来避免在代码中使用 std::
,例如你可以使用 using namespace std;
包含在你的代码中的 main
函数之前,不过这种方式通常不被推荐,因为这样可能会导致命名空间污染(namespace pollution)。