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的更多相关文章

  1. C++ primer chapter 12

    动态内存:之前的程序使用对象有着严格定义的生存期,会自动销毁.C++支持动态分配对象,动态分配对象的生存期和他们在哪里创建是无关的,只有当显式的被释放,这些对象才会销毁.标准库定义了智能指针对象可以自 ...

  2. C++ primer chapter 13

    拷贝 赋值 销毁 拷贝构造函数 如果一个构造函数第一个参数是自身的引用,而且任何额外参数都有默认值,则此构造函数是拷贝构造函数拷贝构造函数的第一个类型必须是引用:如果参数不是引用类型,那么调用不会成功 ...

  3. c++primer chapter one

    一个函数的定义包含四个部分:返回类型(return type),函数名(function name),一个括号包含的形参列表(parameter,允许为空)以及函数体(function body). ...

  4. c++primer chapter three

    3.1命名空间的using声明 using声明具有如下的形式:using namespace :: name; #include <iostream> using std :: cout; ...

  5. laravel code bright

    Project RootLet’s start by taking a look at the root folder structure.• app/• bootstrap/• vendor/• p ...

  6. [笔记] 《c++ primer》书店程序 Chapter 1

    书店程序是<c++ primer>中重要的实例,涉及大部分重要知识点,但代码分散阅读不便,下面按照章节顺序总结 Sales_item.h #ifndef SALESITEM_H // we ...

  7. 《C++ Primer》 chapter 15 TextQuery

    <C++ Primer>中第15章为了讲解面向对象编程,举了一个例子:设计一个小程序,能够处理查询给定word在文件中所在行的任务,并且能够处理“非”查询,“或”查询,“与”查询.例如执行 ...

  8. C++ Primer(第五版)读书笔记 & 习题解答 --- Chapter 3

    Chapter 3.1 1. using声明具有如下的形式: using namespace::name; Chapter 3.2 1. C++标准一方面对库类型所提供的操作做了规定,另一方面也对库的 ...

  9. C++ Primer(第五版)读书笔记 & 习题解答 --- Chapter 2

    Chapter 2.1 1. 数据类型决定了程序中数据和操作的意义. 2. C++定义了一套基本数据类型,其中包括算术类型和一个名为void的特殊类型.算术类型包含了字符.整型.布尔值以及浮点数.vo ...

随机推荐

  1. 翻译一篇SpiderMonkey GC的文章

    前言 这篇文章包含了对SpiderMonkey中Rooted<T>, Handle<T>的解释. 翻译自 https://developer.mozilla.org/en-US ...

  2. Couchbase 使用方法

    1.数据流向 List<模型>  数据-->MsgPack 打包成byte[]-> couchbase 实例调用 Store(Enyim.Caching.Memcached.S ...

  3. [QT]QT概述

    QT概述 基于C++的GUI开发框架,跨平台.Qt 是一个用于桌面系统和嵌入式开发的跨平台应用程序框架. QT是挪威TROLLTECH公司开发的跨平台C++工具,在UNIX下非常出名:他的宗旨是“一次 ...

  4. java基础知识再学习--集合框架-对象的强、软、弱和虚引用

    原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://zhangjunhd.blog.51cto.com/113473/53092 本文 ...

  5. 深度学习word2vec笔记之算法篇

    深度学习word2vec笔记之算法篇 声明:  本文转自推酷中的一篇博文http://www.tuicool.com/articles/fmuyamf,若有错误望海涵 前言 在看word2vec的资料 ...

  6. hdu 1142 A Walk Through the Forest

    http://acm.hdu.edu.cn/showproblem.php?pid=1142 这道题是spfa求最短路,然后dfs()求路径数. #include <cstdio> #in ...

  7. DataGrid导出excel

    DAL://产品信息导出——LPH public DataTable ExportRelease(string type) { string sql = "SELECT [ProductID ...

  8. java设计模式--结构型模式--享元模式

    享元模式 概述 运用共享技术有效地支持大量细粒度的对象. 适用性 当都具备下列情况时,使用Flyweight模式: 1.一个应用程序使用了大量的对象. 2.完全由于使用大量的对象,造成很大的存储开销. ...

  9. Check whether a given Binary Tree is Complete or not 解答

    Question A complete binary tree is a binary tree in which every level, except possibly the last, is ...

  10. Openstack REST API

    There are some high quality resources that already cover the OpenStack API, so this is a YEA (yet an ...