首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

accelerated c++ 学习札记

2012-08-31 
accelerated c++ 学习笔记Chapter 0?A namespace is a collection of related names。Namespaces are a mec

accelerated c++ 学习笔记

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.struct Student_info { string name; double midterm, final; vector<double> homework;}; // note the semicolon it's required?

chapter 4

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_argumentlength_error    out_of_range      runtime_errorrange_error     overflow_error    underflow_error

e.what()

Returns a value that reports on what happened to cause the error.




热点排行