小编Geo*_*iou的帖子

为什么Stroustrup在"The C++ Programming Language 3rd Edition(online)"中定义了sqrt函数?

Bjarne Stroustrup在他的书"The C++ Programming Language"第2章第23页(pdf第34页)的第3版(在线)中,在一个片段范例中定义了该函数sqrt.为什么他不只是使用已经包含在标准库中的那个?

c++

5
推荐指数
1
解决办法
331
查看次数

iostreams操纵者命令

我不理解下面的表达式中的逻辑,虽然它完美地工作:

cout << left << setw(6) << "hello" << "there." ; 
Run Code Online (Sandbox Code Playgroud)

前面的代码正确输出了我的期望: hello there.

我的逻辑是:

cout << "hello" << left << setw(6) << "there."; 
Run Code Online (Sandbox Code Playgroud)

但是它输出了一些意想不到的东西:hellothere.我的期望是"有"的第一个字符"t"在输出区域的第7列之后是6列宽度之后.换句话说,我的概念是"left setw(n)"应该表示"输出区域中第一个的n列(空格)",就像一些带有编号列的数据表格一样,便于查找数据.

你能解释一下吗?

c++ iostream manipulators

4
推荐指数
1
解决办法
129
查看次数

标签 统计

c++ ×2

iostream ×1

manipulators ×1