`
xkxjy
  • 浏览: 42860 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

Accelerated C++ 第三章要点

    博客分类:
  • C
阅读更多

Accelerated C++ 第三章要点

 

Local variables are default-initialized if they are defined without an explicit initializer. Default-initialization of a built-in type means that the value is undefined. Undefined values may be used only as the left-hand side of an assignment.
如果局部变量没有显示初始化,则踏实默认初始化的。内置类型的默认初始化意味着它的值是未定义的。未定义的值只可以用在赋值操作符的左边。

 

Type definitions:
类型定义:

 

typedef type name;   Defines name as a synonym for type.
typedef type name;   定义 name 为 type 的同义词。

 

The vector type, defined in <vector>, is a library type that is a container that holds a sequence of values of a specified type, vectors grow dynamically. Some important operations are:
定义在<vector>中的vector,是标准库定义的一种类型,它是一种能够存储某种指定类型的值序列的容器,vector是动态增长的。一些重要操作如下:

 

vector<T>::size_type
A type guaranteed to be able to hold the number of elements in the largest possible vector.
一种可以存储最大的vector的元素数量的类型,unsigned类型。

 

v.begin()
Returns a value that denotes the first element in v.
返回一个值,它指向v中的第一个元素(迭代器类型)。

 

v.end()
Returns a value that denotes (one past) the last element in v.
返回一个值(还是迭代器),它指向v中最后一个元素的下一个位置。

 

vector<T> v;
Creates an empty vector that can hold elements of type T.
创建一个存储元素类型为 T 的空vector。

 

v.push_back(e)
Grows the vector by one element initialized to e.
使vector增长一个元素,此元素被初始化为e(此元素加载v的最后)

 

v[i]
Returns the value stored in position i.
返回存储在位置i的值。

 

v.size()
Returns the number of elements in v.
返回v的元素数量。

 

Other library facilities
其他库功能

 

sort(b, e)
Rearranges the elements defined by the range [b, e) into nondecreasing order. Defined in <algorithm>.
以非递减的顺序重新排列[b, e)区间的元素。在<algorithm>中定义。

 

max(el, e2)
Returns the larger of the expressions e1 and e2; e1 and e2 must have exactly the same type. Defined in <algorithm>.
返回e1和e2之中较大的那一个;e1和e2必须具有完全相同的类型。在<algorithm>中定义。

 

while (cin >> x)
Reads a value of an appropriate type into x and tests the state of the stream. If the stream is in an error state, the test fails; otherwise, the test
succeeds, and the body of the while is executed.
读取合适类型的值到x并测试流的状态。如果流处于一种错误状态,测试失败;否则,测试成功并且while的语句会被执行。

 

s.precision(n)
Sets the precision of stream s to n for future output (or leaves it unchanged if n is omitted). Returns the previous precision.
设置流s的精度为n(或者当n未给出是不做改变),在以后的输出中起作用。返回以前的精度值。

 

setprecision(n)
Returns a value that, when written on an output stream s, has the effect of calling s.precision(n). Defined in <iomanip>.
当在输出流s上调用时,与调用s.precision(n)作用一样,返回一个值。在<iomanip>定义。

 

streamsize
The type of the value expected by setprecision and returned by precision. Defined in <ios>.
setprecision期待的值类型,precision也返回此类型,在<ios>定义。

分享到:
评论

相关推荐

    Accelerated C++第3章的源代码

    Accelerated C++第3章的源代码,我已经用VC++ 6.0编译运行过了,运行结果OK。与书中代码不同之处:编译时using std::vector不起作用,直接使用vector时出错,改回std::vector编译通过,运行结果正确

    Accelerated C++课本源代码

    Accelerated C++源代码

    Accelerated C++.chm

    《Accelerated C++》真的蛮经典的,被许多人称为小《C++ Primer》,也是公认的C++最佳。 个人认为,只要想学C++的朋友肯花几个月时间认真去掰以下这组书,我相信你的C++就算入门了: 《Accelerated C++》+《The C++ ...

    Accelerated C++ 前三章答案

    Accelerated C++ 前三章答案

    Accelerated C++ 源代码

    Accelerated C++ 源代码

    Accelerated C++ 英文版

    《Accelerated C++》的作者Andrew Koenig是C++标准化过程中的核心人物之一。C++不同于C的一个关键地方就在于,C++在完全保留有C的高效的基础上,增添了抽象机制。而所谓的“现代C++风格”便是倡导正确利用C++的抽象...

    Accelerated C++: Practical Programming by Example

    That’s the approach that’s offered by Accelerated C++, a text that delves into more advanced C++ features like templates and Standard Template Library (STL) collection classes early on. This book ...

    Accelerated C++中文.pdf

    Accelerated C++中文.pdfAccelerated C++中文.pdfAccelerated C++中文.pdf

    Accelerated c++中文版 源代码

    Accelerated c++中文版 源代码,源代码按章节包含在每个文件夹中,方便调试,节省敲代码时间

    Accelerated C++第四章节例题程序

    Accelerated C++第四章节讲到了多文件编程,本例子很好的组织了文章所提到的方法编写的例子,可以用来参考学习多文件编程

    Accelerated C++ 无水印pdf

    Accelerated C++ 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

    Accelerated C++中文版

    Accelerated C++中文版 pdf

    Accelerated C++中文版(扫描版)

    Accelerated C++: Practical Programming by Example 《Accelerated C++中文版》,中国电力出版社 和市面上大多数C++教程不同,本书不是从“C++中的C”开始讲解,而是始于地道的C++特性。从一开始就使用标准库来写...

    Accelerated C++ 习题答案

    Accelerated C++ 习题答案

    accelerated c++

    Based on the authors' intensive summer C++ courses at Stanford University, Accelerated C++ covers virtually every concept that most professional C++ programmers will ever use -- but it turns the '...

    Accelerated C++答案.rar

    Accelerated C++随书答案。该书作者提供的源码。全部都有

    Accelerated_C++中文版g.pdf

    Accelerated_C++中文版g

    Accelerated C++ (中文版) PDF

    Accelerated C++ (中文版) PDF~~~~~~

    Accelerated C++中文 pdf

    Accelerated C++中文影印版 pdf格式,没找到手写版的,不知道有没有。

Global site tag (gtag.js) - Google Analytics