`
xkxjy
  • 浏览: 43515 次
  • 性别: 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++第四章节例题程序

    第四章涉及的多文件编程是C++中的一项重要技能,尤其是在大型项目中,代码的组织和模块化变得至关重要。本例题程序旨在帮助读者理解并掌握如何在多个源文件之间划分职责,以及如何有效地进行编译和链接。 在C++中,...

    Accelerated C++第3章的源代码

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

    Accelerated C++ 中文英文两版高清

    《Accelerated C++》是一本深受程序员喜爱的C++进阶教程,旨在帮助已经具备C或C++基础知识的学习者快速提升编程技能。该书由Andrew Koenig和Barbara E. Moo共同撰写,以其独特的教学方法和高效的学习路径著称。 这...

    Accelerated C++ 前三章答案

    文件"Accelerated C++ C2.doc"、"Accelerated C++ C0.doc"和"Accelerated C++ C1.doc"很可能是对应每个章节的解答文档,分别覆盖了第二章、第一章和第三章的内容。这些文档可以作为学习资源,帮助读者对照书中习题的...

    Accelerated c++中文版 源代码

    《Accelerated C++》是一本深受程序员喜爱的C++学习书籍,它以其高效、实践性强的特点,引导读者快速掌握C++编程基础。源代码是学习编程的重要组成部分,尤其是在阅读和理解书中实例时,能直接查看并运行代码对于...

    Accelerated C++.chm

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

    《Accelerated C++》是一本深受程序员喜爱的C++编程教程,由Andrew Koenig和Barbara E. Moo合著。这本书旨在通过一种快速而有效的方式教授C++,让学习者能够迅速掌握C++的核心概念和实践技巧。中文影印版的出现,...

    Accelerated C++课本源代码

    《Accelerated C++》是一本由Andrew Koenig和Barbara E. Moo共同编著的C++编程教材,它的核心理念是通过实践教学,让学习者快速掌握C++语言的关键概念和技术。这本书的设计旨在打破传统的编程教程模式,通过精心设计...

    Accelerated_C++中文版g.pdf

    从提供的文件信息来看,《Accelerated_C++中文版》是一本关于C++编程语言的教科书。考虑到标题和描述均为“Accelerated_C++中文版”,并且提供了大量的占位字符作为“部分内容”,这表明该文件可能是由OCR扫描技术从...

    Accelerated C++ 源代码

    《Accelerated C++》是一本深受程序员喜爱的C++编程教材,它以其独特的教学方法和实践导向性,帮助读者快速掌握C++的核心概念和技术。源代码是学习编程的重要辅助资料,能够直观地展示理论知识在实际应用中的表现。...

    Accelerated C++中文版

    《Accelerated C++中文版》是一本专为C++初学者设计的教材,旨在帮助他们快速掌握C++这门编程语言。C++是一种广泛使用的高级编程语言,它支持多种编程范式,包括过程化、面向对象和泛型编程。本书通过循序渐进的方式...

    Accelerated C++答案.rar

    《Accelerated C++》是Andrew Koenig和Barbara E. Moo合著的一本C++编程教材,以其独特的教学方式和高效的学习路径而备受推崇。这本书旨在帮助初学者快速掌握C++语言的核心概念,同时也适合有经验的程序员作为进阶...

    Accelerated C++: Practical Programming by Example(解密PDF)

    综上所述,《Accelerated C++:通过实例学习实用编程》通过丰富的实例和深入浅出的讲解,为读者提供了一个全面学习和掌握C++编程的良好起点,适合各个层次的C++程序员使用,对于希望深入掌握C++编程的读者来说,这是...

    Accelerated C++中文.pdf

    根据提供的信息,我们可以推断这份文档是关于《Accelerated C++》这本书的中文版内容。虽然实际的内容似乎是由无法解析的字符组成,但从标题、描述和标签中,我们可以推测这是一份关于加速学习C++编程语言的指南。...

Global site tag (gtag.js) - Google Analytics