《C++ primer》(4th)读书笔记(1 start)


0,Preface等相关

 structure of this book:

Much of the power of C++ comes from its support for programming with abstrctions. ... our focus is on how to use the features in C++ to write programs that are safe, that can be built quickly, and yet offer performance comparable to the sorts of low-level programs often written in C.

Modern C++ can be thought of as comprising three parts:

  •      The low-level language, largely inherited from C.
  •      More advanced language features that allow us to define our own data types and to organize large-scale        programs and systems.
  •     The standard library, which uses these advanced features to provides a set of useful data structures and   algorithms.
Parts I and  II (1~2) cover the basic language and library facilities.
Parts III through V (3~5) focus on how we can write our own types.

(由于之前已经不系统的学过了相当多的编程知识,这次系统性的学习应该有一些新的切入角度。考虑能否在底层思想上从Turing Machine的基本计算模型、算法的基本思想来重新的认识C++、乃至这些高级语言的一般特征,以便最终真正的理解OO等关键的思想?对此将进行尝试。)

1,Getting Started

1.1 程序基本结构
   A function definition specifies four elements: the return type, the function name, a (possible empty) parameter list enclosed ion parentheses, and the function body.

(ubuntu下安装g++编译器命令:  sudo apt-get install build-essential )
 
1.2 语句基本样式
     “endlis a special value, called a manipulator , that when written to an output stream has the effect ofwriting a new line to the output and flushing the buffer associated with that device. By flushing the buffer, we ensure that the user will see the output written to the stream”
 
       NOTE:Programmers often insert print statements during debugging. Such statements should always flush the stream. 

      养成在定义变量时,对其进行初始化的习惯“When we define a variable, we should give it an initial value unless we are certain that the initial value will be overwritten before the variable is used for any other purpose. If we cannot guarantee that the variable will be reset before being read, we should initialize it”
1.3 注释相关
      大段的注释最好明确的在每一行注释前加上标记确认其属于注释!“When a comment pair does  span multiple lines, it is often a good idea to indicate visually that the inner lines are part of a  multi-line comment.”    
1.4 基本控制结构介绍
介绍了while、for、if三种基本的流程控制结构。此外:
    介绍了如何 Reading an Unknown Number of Inputs:
   “When we use an istream as a condition, the effect is to test the state of the stream. If the stream is valid that is, if it is still possible to read another input then the test succeeds. An istream becomes invalid when we hit end-of-file or encounter an invalid input, such as reading a value that is not an integer. An istream that is in an invalid state will cause the condition to
fail.”
“Operating systems use different values for end-of-file. On Windows systems we enter an end-of-file by typing a control-zsimultaneously type the "ctrl" key and a "z." On UNIX systems, including Mac OS-X machines, it is usually control-d.

 #include <iostream>
 int main()
 {
     int sum = 0, value;
     // read till end-of-file, calculating a running total of all values read
     while (std::cin >> value)
         sum += value; // equivalent to sum = sum + value
     std::cout << "Sum is: " << sum << std::endl;
     return 0;
  }
1.5  class类简介

class是C++的重要特点,它的目的就是更加方便程序员创建自己的数据 type从而更好地表达自己想要的的数据结构。这本书里在这第一部分就引入了class的内容,一方面是先给一个overview of whole C++,另一方面是体现了class是一种很好的封装性的元素,我们完全可以在不知道它的实现细节的基础上高效的使用它让它为我们所用!(To use a class, we need not know anything about how it is implemented. Instead, what we need to know is what operations the class provides.)
To use a class we need to know three things:
1.What is its name? 
2.Where is it defined? 
3.What operations does it support? 

   class的定义文件中不仅定义了它的包含元素,而且定义了所有可以使用的behavior。
  NOTE:Headers for the standard library are enclosed in angle brackets (<  >). Nonstandard headers are enclosed in double quotes ("  " ).



1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READme.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 、 1资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READmE.文件(md如有),本项目仅用作交流学习参考,请切勿用于商业用途。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通;、本 3项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看ReadmE.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 、资 1源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READMe.m文件(如d有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值