Extraction from C++ Primer 5th. Editioin 3.2.1

C++ has several different forms of initialization, we should understand how these forms differ from one aother.

When we initialize a variable using =, we are asking the compiler to copy initialize the object by copying the initializer on the right-hand side into the object being created.

Ohterwise when we omit the =, we use direct intialization.When we have a single intializer, we use either the direct or copy form of intialization. When we intialize a variable from more than one value, such as:

string s4(, 'c');

we must use the direct form of initialization.

when we want to use several values, we can indirectly use the copy form of intialization be explicitly creating a (temporary) object to copy:

string s8=string(, 'c');    //copy initialization

The intializer of s8——string(10, 'c')——creates a string of the given size and character value and then copies that value into s8. it is as if we had written

string temp(, 'c');
string s8=temp;

Although the used to intialize s8 is legal, it is less readable and offers no compensating advantage over the way we intilize s4.

最新文章

  1. 关于在Linux64位下安装xampp
  2. learn mips
  3. AngularJs--angular-pagination可复用的分页指令
  4. vbscript input select 添加个option根据value值到指定位置--相当于排序
  5. Servlet下载文件和http响应
  6. Java多线程系列--“JUC线程池”05之 线程池原理(四)
  7. MVC认知路【点点滴滴支离破碎】【四】----捆绑和缩小(BundleConfig.RegisterBundles)
  8. Shell 脚本 ,, 根据进程号退出 从而关机
  9. MVC中return File(byte[],"image/jpeg")输入图片不清晰
  10. java专业规划(转载)
  11. 百度富文本编辑器UEditor1.3上传图片附件等
  12. 6.解决AXIOS的跨域问题
  13. python键盘读入的input方法
  14. MassTransit 实现发布/订阅
  15. 第十四章——循环神经网络(Recurrent Neural Networks)(第一部分)
  16. shell 重定向 2>&1 2>/dev/null 理解笔记
  17. Python中的xxx == xx是否等价于xxx is xxx
  18. 概率图模型 基于R语言 这本书中的第一个R语言程序
  19. VUE 打包后关于 -webkit-box-orient: vertical; 消失,导致多行溢出不管用问题
  20. DES加解密 cbc模式 的简单讲解 && C++用openssl库来实现的注意事项

热门文章

  1. webapp:移动端高清、多屏适配方案(zz)
  2. 【Flex】正则表达式
  3. Theano2.1.2-基础知识之第一步:代数
  4. 谈对象 MVC 和 多端
  5. C#:异步编程和线程的使用(.NET 4.5 )
  6. 检测IE浏览器方法
  7. Rectangles Area Sum
  8. PHP-- 三种数据库随机查询语句写法
  9. linux基础-第十五单元 软件包的管理
  10. linux基础-第十三单元 硬盘分区、格式化及文件系统的管理二