C++ Primer Chapter 1
When I start reviewing, I thought Chapter is useless. Because the title is “Getting Start” . I thought that is useless. But I found something I miss before, so I review it and found I understand something that confused me. So every parts is useful in this book.
The first function is very simple so we don’t have to explain it anymore. But how to compile it? I don’t think the book write well in this part. I will show you how to use cmd to compile it in Windows but I don’t have a Linux PC so I can’t show how to compile it in Linux.
1. You should install VC. I install Visual Studio 2013 so I have VC.
2. Locate your VC. Like me, my VC is locate here C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
3. Right click “This PC” and click “Properties” .Advanced system settings->Advanced->Environment Variables. Find “path” in “User Variable for XXX” .If there is no “path”, create one. Also, create two variable named “include” and “lib”.
4. Edit “path” by adding two addresses. First is where your VC/bin are. For me is “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin”. Second is in your “Microsoft Visual Studio X.0/Common7\IDE” folder. For me is “C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE”.
5. Edit “lib” by adding two addresses. First is where your VC/lib are. For me is “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib”. Then use search where uuid.lib are. And add the address of it. You should separate two addresses by adding “;”.
6. Edit “include” by adding where your VC/include are. For me is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include.
7. OK, now you have done building your developing environment. You can use cmd to compile your program in the way the book introduces in p.5.
I/O is not defined by the language itself so we should define it by using the IO library named iostream. A stream is a sequence of characters read from or written to an IO device. But remember cin and cout is an object of type istream and ostream. This is important to remember that cin is not the same as istream and cout is not the same as ostream. We include a header by using “#include”. We will know in the following chapter that if we writer our own header, we should use #include “(your header)” (double quotes) and the standard library #include<(library)>.
endl can end the current line. However “\n” can also do that. The different between them is that endl can flush the buffer. This ensures that all the output is written to the output stream rather than staying in the memory. For me, I prefer using endl.
Namespace is useful, it can, to some degree, avoid some mistake we may make. All names defines by the standard library are in the std namespace.
For flow of control, I will discuss it in the following article.
Class, I think, is the most important part in C++. By writing a class we can define our own data structure. A class defines a type. Sometime you will see a program that the source is just a few line but has a lot of class and the class is complicate. Member function is defined in the class. We can decide what the member function when we write the class. We can use the member function by using the dot operator (“.”) . Like the main function, when we use a function, we should use a call operator, no matter if there is any arguments.
OK, that’ all. That is what the chapter 1 says. I will write something about Chapter 2 in the next blog.
C++ Primer Chapter 1的更多相关文章
- C++ primer chapter 12
动态内存:之前的程序使用对象有着严格定义的生存期,会自动销毁.C++支持动态分配对象,动态分配对象的生存期和他们在哪里创建是无关的,只有当显式的被释放,这些对象才会销毁.标准库定义了智能指针对象可以自 ...
- C++ primer chapter 13
拷贝 赋值 销毁 拷贝构造函数 如果一个构造函数第一个参数是自身的引用,而且任何额外参数都有默认值,则此构造函数是拷贝构造函数拷贝构造函数的第一个类型必须是引用:如果参数不是引用类型,那么调用不会成功 ...
- c++primer chapter one
一个函数的定义包含四个部分:返回类型(return type),函数名(function name),一个括号包含的形参列表(parameter,允许为空)以及函数体(function body). ...
- c++primer chapter three
3.1命名空间的using声明 using声明具有如下的形式:using namespace :: name; #include <iostream> using std :: cout; ...
- laravel code bright
Project RootLet’s start by taking a look at the root folder structure.• app/• bootstrap/• vendor/• p ...
- [笔记] 《c++ primer》书店程序 Chapter 1
书店程序是<c++ primer>中重要的实例,涉及大部分重要知识点,但代码分散阅读不便,下面按照章节顺序总结 Sales_item.h #ifndef SALESITEM_H // we ...
- 《C++ Primer》 chapter 15 TextQuery
<C++ Primer>中第15章为了讲解面向对象编程,举了一个例子:设计一个小程序,能够处理查询给定word在文件中所在行的任务,并且能够处理“非”查询,“或”查询,“与”查询.例如执行 ...
- C++ Primer(第五版)读书笔记 & 习题解答 --- Chapter 3
Chapter 3.1 1. using声明具有如下的形式: using namespace::name; Chapter 3.2 1. C++标准一方面对库类型所提供的操作做了规定,另一方面也对库的 ...
- C++ Primer(第五版)读书笔记 & 习题解答 --- Chapter 2
Chapter 2.1 1. 数据类型决定了程序中数据和操作的意义. 2. C++定义了一套基本数据类型,其中包括算术类型和一个名为void的特殊类型.算术类型包含了字符.整型.布尔值以及浮点数.vo ...
随机推荐
- Hdu1094
#include <stdio.h> int main() { ; while(scanf("%d",&n)!=EOF){ ;i<n;i++){ scan ...
- linux下snprintf和sprinf很少被提及的区别
函数原型:int snprintf(char *dest, size_t size, const char *fmt, ...);函数说明: snprintf函数中的第二个参数,size的解释:siz ...
- Bootstrap 模态对话框 remote指定内容加载
第一个页面: .....其他内容..... <div class="modal" id="ID_ReformDetail"> <div cla ...
- 开心菜鸟系列学习笔记------------javascript(6)
一.作用域链 1)函数的生命周期: 函数的生命周期分为创建和激活阶段(调用时),让我们详细研究它. 作用域链与一个执行上下文相关,变量 ...
- LeetCode_N-Queens
The n-queens puzzle is the problem of placing n queens on an n�n chessboard such that no two queens ...
- Qt5.3企业版和开源版功能区别
一: Charts Charts是QT提供的图表模块.他提供了非常简便的APIs来绘制令人惊叹的Line, Spline,Area,Scatter,Pie,Donut,Bar,Polar和Box-an ...
- Vim 默认开启行号、语法显示等设置
在终端下使用vim进行编辑时,默认情况下,编辑的界面上是没有显示行号.语法高亮度显示.智能缩进等功能的.为了更好的在vim下进行工作,需要手动设置一个配置文件:.vimrc. 在启动vim时,当前 ...
- 使用httpclient抓取时,netstat 发现很多time_wait连接
http://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions 1. Connections in ...
- UVa 11401 三角形的个数
题意:由1,2,3...n组成的序列中找三个数,且以这三个数为变长能组成三角形,求这样的三角形个数. 思路:当每次输入n时重新都计算一遍会TLE...先预处理,将结果存入ans数组. 代码: #inc ...
- Word Pattern II 解答
Question Given a pattern and a string str, find if str follows the same pattern. Here follow means a ...