- 浏览: 214421 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
microwindlab:
你不应该加 --shell 参数,因为 --shell run ...
由mongodb的维护引发的 grep,awk,sed 与管道的应用 -
Jerryhome:
楼主超牛,值得好好学习
windows系统下的进程监测程序--实现过程记录 -
xb_91674981:
学习一下,模式在程序设计是很重要
《大话设计模式》一书的所有代码和UML类图 -
Jason(aijun):
正在学习,非常感谢分享。
《大话设计模式》一书的所有代码和UML类图 -
wurb_travelsky:
正在看这本书,C#的代码倒也不影响阅读
《大话设计模式》一书的所有代码和UML类图
Chapter 0
A namespace is a collection of related names。Namespaces are a mechanism for grouping related names.
the standard library uses std
to contain all the names that it
defines. So, for example, the iostream
standard header defines the
names cout
and endl
, and we refer to these names as
std::cout
and std::endl
.
output operator
, <<。
<<
is left-associative
, which, loosely
speaking, means that when <<
appears twice or more in the
same expression, each <<
will use as much of the expression
as it can for its left operand, and as little of it as it can for its right
operand.
An expression contains operators and operands。Every operand has a type。 a type denotes a data structure and the meanings of operations that make sense for that data structure.
std::endl
, which is a manipulator。
<<
does whatever the manipulator says to do to the given
stream, and returns the stream as its result。
The scope of a name is the part of a program in which that name has its meaning。
The standard library defines all of its names in a namespace named
std
, so that it can avoid conflicts with names that we might define
for ourselves-as long as we are not so foolish as to try to define
std
.
::
operator. This operator is also known as the scope
operator。
std::cout
means "the name cout
that is in the
(namespace) scope std
."
Types define data structures and operations on those data structures.
C++ has two kinds of types: those built into the core language, such as
int
, and those that are defined outside the core language, such as
std::ostream
.
The main function:
A zero return from main
indicates success; a nonzero return
indicates failure.
It may omit the return; explicitly including a return from main
is good practice
chapter 1
three events that cause the system to flush the buffer.
First, the buffer might be full.
Second, the library might be asked to read from the standard input stream.
The third occasion for flushing the buffer is when we explicitly say to do so.
+
to concatenate
a string
the +
operator (and, for that matter, the >>
operator) is also left-associative.
s+t : Either s
or t
, but not both, may be a string
literal or a value of type char
.
When an operator has different meanings for operands of different types, we say that the operator is overloaded .
string construct method:
std::string spaces(greeting.size(), ' ');
wchar_t
hold characters for languages such as Japanese.
using std::cout;
size_t
<cstddef>
)
that can hold any object's size string::size_type
string
<ios>
header defines streamsize
, which is
the type that the input-output library uses to represent sizes. <iomanip>
header defines the manipulator
setprecision
, which lets us say how many significant digits we want
our output to contain.endl
manipulator is used so often that its definition appears
in <iostream>
setprecision(3)
, we ask the implementation to write grades with
three significant digits, generally two before the decimal point and one after.sort(homework.begin(), homework.end());
sort
function, defined in the <algorithm>
header, rearranges the values in a container so that they are in nondecreasing
order. typedef type name
;
Defines name
as
a synonym for type.
vector<T> v;
T
. v.push_back(e)
e
. s.precision(n)
s
to n
for future output (or leaves it unchanged if n
is omitted). Returns
the previous precision. setprecision(n)
s
, has the effect of calling s.precision(n)
. Defined
in <iomanip>
. streamsize
setprecision
and returned by precision
. Defined in <ios>
.
const vector<double>&
, that we specify for the third
argument. This type is often called "reference to vector
of
const double
." // chw is a read-only synonym for homework const vector<double>& chw = homework;
const
promises that we will not do anything to chw that might
change its value.const
reference" refer to a const
object or referencevector<double>& hw2 = chw; // error: requests write access to chw
clear
member behaves completely differently for
istream
objects than it does for vector
objects. For istream
objects, it resets any error indications so that input
can continue; { }
that follow the try
keyword. If a domain_error
exception occurs anywhere in these statements, then it stops executing them and
continues with the other set of { }
-enclosed statements. These
statements are part of a catch
clause
,
which begins with
the word catch
, and indicates the type of exception it is catching.// this example doesn't work
try {
streamsize prec = cout.precision();
cout << "Your final grade is " << setprecision(3)
<< grade(midterm, final, homework) << setprecision(prec);
} ...
// compute and generate the final grade, if possible try { double final_grade = grade(midterm, final, homework); streamsize prec = cout.precision(); cout << "Your final grade is " << setprecision(3) << final_grade << setprecision(prec) << endl; } catch (domain_error) { cout << endl << "You must enter your grades. " "Please try again." << endl; return 1; }
Student_info
is a type,
which has four data members. struct Student_info { string name; double midterm, final; vector<double> homework; }; // note the semicolon it's required
Exception classes: The library defines several exception classes whose names suggest the kinds of problems they might be used to report:
logic_error domain_error invalid_argument length_error out_of_range runtime_error range_error overflow_error underflow_error
e.what()
发表评论
-
w3school html 学习笔记
2014-04-25 20:38 877当显示页面时,浏览 ... -
phpcms 笔记
2014-04-24 16:53 819Phpcms v9的pc_webserver一安装上,就不 ... -
dive into python 笔记
2014-02-13 17:23 619第三章 tuple 是没有app ... -
python 爬某高校C++题库小程序
2014-01-18 15:44 1388最近在学习C++,爬下一些题来,用于平时练手。 原理其实也 ... -
centos下饭强--obfucated-openssh sshcenter.info
2013-09-26 21:47 14981. git clone https://github.com ... -
android的【qq通讯录】导出短信,在iphone上恢复
2013-07-14 22:00 5921事件经过:朋友原来用android手机,现在新买了ipho ... -
python的一些记录
2013-05-03 13:53 1143正则表达式的一些常用元字符和语法: http://www. ... -
《程序设计导引及在线实践》学习
2012-05-31 17:13 999P41 int MyItoa(char s[]) 将s中以 ... -
关于foreach与普通for的区别
2012-04-10 22:07 1286请问两者的区别 for(A a : alist) { ... -
学习Linux命令,读《系统程序员成长计划》
2012-03-06 16:41 1299linux命令小结: cat : ... -
base64,日期操作,jexl读取excel
2012-03-06 16:40 215407-22:学习base64的加密和解密,求几天前的日期和求两 ... -
无题。。好代码记录
2011-12-27 11:35 737编写函数expand(s1,s2),将字符串s1中类似于a-z ... -
数据结构:排序
2011-11-09 13:08 909排序一般分为:插入排序,选择排序,交换排序,归并排序和分配排序 ... -
c语言复习笔记
2011-11-07 17:24 2081指针部分: 1.指针类型说明 main(){ in ... -
并发学习笔记(更新中,java编程思想第四版21章)
2011-10-19 23:47 1548实现并发最直接的方式是在操作系统级别使用进程。 并发任 ... -
并发学习笔记(更新中,java编程思想第四版21章)
2011-10-19 21:05 0从今天起记录学习到的知识。 -
RMI 入门
2011-10-07 16:23 1514RMI : remote method invocation, ... -
《大话设计模式》一书的所有代码和UML类图
2011-08-29 16:08 4249如题,把《大话设计模式》一书的所有代码和UML类图写出来,见附 ... -
windows系统下的进程监测程序--实现过程记录
2011-05-26 22:50 6154单位的客服中心的服务器有个接口程序,这三天都出现了自动退出的情 ... -
发短信算法题
2011-05-10 20:49 1109发短信:手机短信通常a个字就分一页,分页之前在短信之前都要加上 ...
相关推荐
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++》真的蛮经典的,被许多人称为小《C++ Primer》,也是公认的C++最佳。 个人认为,只要想学C++的朋友肯花几个月时间认真去掰以下这组书,我相信你的C++就算入门了: 《Accelerated C++》+《The C++ ...
Accelerated C++源代码
而所谓的“现代C++风格”便是倡导正确利用C++的抽象机制和这些机制构建出来的现代C++库(以STL为代表)的,Bjarne也很早就倡导将C++当作一门不同于C的新语言来学习(就拿内存管理来说,使用现代C++的内存管理技术,...
Accelerated C++ 源代码
Accelerated C++中文.pdfAccelerated C++中文.pdfAccelerated C++中文.pdf
Accelerated C++ 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Accelerated C++: Practical Programming by Example 《Accelerated C++中文版》,中国电力出版社 和市面上大多数C++教程不同,本书不是从“C++中的C”开始讲解,而是始于地道的C++特性。从一开始就使用标准库来写...
Accelerated C++中文版 pdf
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++ (中文版) PDF~~~~~~
Accelerated c++中文版 源代码,源代码按章节包含在每个文件夹中,方便调试,节省敲代码时间
Accelerated C++ 这本书是快速提升编程水平的书,适合已经学过C或者C++基础的人看
Accelerated C++中文影印版 pdf格式,没找到手写版的,不知道有没有。
Accelerated_C++中文版g
和市面上大多数C++教程不同,本书不是从"C++中的C"开始讲解,而是始于地道的C++特性....顺带一提,在Bjarne和我最近的一封通信里,他这样评价本书:对于有经验的程序员学习C++而言,这本书可能是世界上最好的一本.
Accelerated C++ Practical Programming by Example-2000-Addison Wesley-chm and Source