符号 endl 和 cout 无法解析

symbol endl and cout could not be resolved

本文关键字:cout endl 符号      更新时间:2023-10-16

我从我正在阅读的一本书中编写了这段代码,但我的编译器警告说符号cout和endl无法解析。为什么。

#include <iostream>
#include <float.h>
int main()
{
    cout << "float: " << endl
         << "stevilo decimalnih mest: " << FLT_DIG         << endl
         << "natancnost stevila....: " << FLT_EPSILON      << endl
         << "Najmanjse stevilo.....: " << FLT_MIN          << endl
         << "Najvecje stevilo......: "  << FLT_MAX         << endl
         << "Bitov v mantisi.......: "  << FLT_MANT_DIG    << endl
         << "Najvecji eksponent....: "  << FLT_MAX_10_EXP  << endl
         << "Najmlajsi eksponent...: "  << FLT_MIN_10_EXP  << endl;
    return 0;
}

您必须使用命名空间:

#include <iostream>
#include <float.h>
using namespace std;

或:

std::cout

您可以在此处阅读有关 c++ 中命名空间的更多信息

coutendl的作用域。因此,您必须告知在哪个命名空间中。

std::cout
std::endl

或在包含后添加错误

using namespace std;