《Beginning C++17》-学习笔记-Chapter 01-Basic Ideas

书名:Beginning C++17 - From Novice to Professional

作者:Ivor Horton, Peter Van Weert

笔记:

Blocks can be placed inside other blocks—this concept is called nesting. Blocks can be nested, one within another, to any depth.

main() is the only function for which omitting return is equivalent to returning zero. Any other function with return type int always has to end with an explicit return statement—the compiler shall never presume to know which value an arbitrary function should return by default.

The names in the Standard Library are all defined within a namespace that has the name std.

Those two colons together, ::, have a fancy title: the scope resolution operator.

The main() function must not be defined within a namespace. Things that are not defined in a namespace exist in the global namespace, which has no name.

In C++, hexadecimal values are written with 0x or 0X as a prefix.

signed magnitude representation: each number consists of a sign bit that is 0 for positive values and 1 for negative values, plus a given number of other bits that specify the magnitude or absolute value of the number (the value without the sign in other words).

Octal values are written with a leading zero.

扫描二维码关注公众号,回复: 4313564 查看本文章

-3.65 × 10-3, which is -0.00365. They’re called floating-point numbers for the fairly obvious reason that the decimal point “floats” and its position depends on the exponent value.

single precision includes 1 sign bit, 8 bits for the exponent, and 23 for the mantissa, adding up to 32 bits in total and double precision is (1 + 11 + 52 = 64 bits) floating-point numbers.

UCS(Universal Character Set) is defined by the standard ISO 10646 and has codes with up to 32 bits. UCS突破了ASCII最多只能代表256个字符的限制。

Unicode provides more than one character encoding method. The most commonly used encodings are referred to as UTF-8, UTF-16, and UTF-32, either of which can represent all the characters in the Unicode set. You have four integer types that store Unicode characters. These are types char, wchar_t, char16_t, and char32_t.


Form feed/*换页符*/ is a page-breaking ASCII control character. It forces the printer to eject the current page and to continue printing at the top of another. Often, it will also cause a carriage return.

#include <stdio.h>
int main()
{
    printf("Hello\fWorld!\n");
    return 0;
}

 输出:


You actually do not have to escape the single quote character, ', inside string literals.

#include <iostream>
int main()
{
	std::cout << "Do you know how to spell the word \'said\'?" << std::endl;/*Add or remove those two back slashes will produce the same result.*/
}

Output:


猜你喜欢

转载自blog.csdn.net/CodingIsFun/article/details/83619577
今日推荐