Skip to content

C++ 笔记

iostream 标准输入输出流;

包含了 cin 标准输入对象,cout 标准输出对象,cerr 标准错误对象,clog 标准输出日志对象。

1
2
3
int num1 = 0, num2 = 0;
    std::cin >> num1 >> num2;
    std::cout << "第一个数:" << num1 << "第二个数:" << num2 << "\t和为:" << num1 + num2 << std::endl;

输出语句中 endl是一个特殊值,作用是结束当前行,保证到目前为止的输出都真正的写入了输出流中,而不是仅仅停留在内存中,并带有换行效果。

cout 和 endl 都定义在std 的命名空间中。

读到firefox,43页