What & How & Why

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
cs:programming:cpp:cpp_primer:2_var_n_types [2024/01/15 00:33] – ↷ 链接因页面移动而自动修正 50.16.62.182cs:programming:cpp:cpp_primer:2_var_n_types [2024/04/16 11:38] (当前版本) – [指针与 constexpr] codinghare
行 113: 行 113:
 ==List 初始化== ==List 初始化==
  
-其中带 //curly braces// 的初始化形式是新标准, 称之为 //List Initialization//。 C++ Primer 的作者推荐使用这种形式。原因是 List 初始化自带类型校验:List 初始化不允许**类型转换**( //Type Conversion// ) 带来的 //Narrowing Conversion//。比如:+其中带 //curly braces// 的初始化形式是新标准, 称之为 //List Initialization//。 C++ Primer 的作者推荐使用这种形式。原因是 List 初始化自带类型校验:List 初始化不允许**类型转换** (//Type Conversion//) 带来的 //Narrowing Conversion//。比如:
 <code cpp> <code cpp>
 double x = 3.1415926; double x = 3.1415926;
行 309: 行 309:
 int **ppi = &pi; //&pi is the address of the pointer, not the address which pointer points int **ppi = &pi; //&pi is the address of the pointer, not the address which pointer points
 </code> </code>
 +\\ \\ 
 +{{ :cs:programming:cpp:cpp_primer:ppi.svg?250 |}}
 +\\ \\ 
  
-<html><div align="center"> 
-<img src="/_media/programming/cpp/cpp_primer/ppi.svg"  width="350"/> 
-</div> 
-</html>\\  
 当然,如果需要通过 ''ppi'' 来访问 ''i'' 的内容,我们需要解引用两次: 当然,如果需要通过 ''ppi'' 来访问 ''i'' 的内容,我们需要解引用两次:
 <code cpp> <code cpp>
行 561: 行 560:
 ''const int *const p'' 这样的形式换成 constexpr 来定义可以写成这样: ''const int *const p'' 这样的形式换成 constexpr 来定义可以写成这样:
 <code cpp> <code cpp>
-constexpr const int *p = &i; //是不是清爽多了哈哈+constexpr const int *p = &i;
 </code> </code>
 Ref:[[http://www.cprogramming.com/c++11/c++11-compile-time-processing-with-constexpr.html|Constexpr - Generalized Constant Expressions in C++11]] Ref:[[http://www.cprogramming.com/c++11/c++11-compile-time-processing-with-constexpr.html|Constexpr - Generalized Constant Expressions in C++11]]