[c++] Basic ideas and Style Guide
Get your own compiler:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.9
you can then compile using the command:
g++-4.9 -std=c++14 -Wall -Werror -O2 -o helloworld helloworld.cpp
Style Rules:
Macros should never be required in C++.
Variables should be defined close to their use.
Don’t use malloc/realloc, use new (or smart pointers)
Minimise use of void*, pointer arithmetic, union and c-style casts
Minimise the use of C-style arrays and strings, use vector/array (from C++11) and string instead.
总之,忘掉C语言。
C++ Standard Library
For efficiency reasons, STL is not object-oriented:
- Makes little use of inheritance, and
- Makes no use of virtual functions
The Standard Template Library (STL) is a part of the C++ standard library, Some others are:
分类一:
- The C standard library
- Language support: <exception>, <ctime>, ...
- Strings: <string>, <cstring>, ...
- Numerics: <cmath>, <complex>, ...
- I/O: <iostream>, <fstream>, <cstdio>, ...
- Exception classes
- Smart pointers
- Classes for internationalisation support
分类二:
Containers: vector, list, stack, ...
Algorithms: find, sort, copy, ...
Iterators are the glue between the two!
The compilation process:
1. Preprocessing - handles meta-information (e.g., #include)
2. Compiling - translates C++ into machine code objects
3. Linking - merges objects into a single application
对语言风格的实践就是最好的学习路径。明白了作者的风格定义思路,也就意味着语言学习达到了优良水准。
路漫漫其修远兮…… 除了坚持,没有捷径。Good luck!
[c++] Basic ideas and Style Guide的更多相关文章
- Google C++ Style Guide
Background C++ is one of the main development languages used by many of Google's open-source project ...
- Airbnb JavaScript Style Guide
Airbnb JavaScript Style Guide() { 用更合理的方式写 JavaScript ES5 的编码规范请查看版本一,版本二. 翻译自 Airbnb JavaScrip ...
- Dojo Style Guide
Contents: General Quick Reference Naming Conventions Specific Naming Conventions Files Variables Lay ...
- 与你相遇好幸运,The Moe Node.js Code Style Guide
The Moe Node.js Code Style Guide By 一个最萌的开发者 @2016.9.21 >>代码是人来阅读的,格式规范的代码是对编程人员最好的礼物 :) > ...
- 使用tdcss.js轻松制作自己的style guide
http://jakobloekke.github.io/tdcss.js/ 在前端开发中,如果能够有一个style guide对于设计来说就显得专业稳定,一致性.在上述链接中,有一个tdcss.js ...
- Google C++ Style Guide在C++11普及后的变化
转 http://www.cnblogs.com/chen3feng/p/5972967.html?from=timeline&isappinstalled=0&lwfrom=user ...
- Common Lisp Style Guide - Ariel Networks Labs
Common Lisp Style Guide - Ariel Networks Labs Common Lisp Style Guide
- 一张图总结Google C++编程规范(Google C++ Style Guide)
Google C++ Style Guide是一份不错的C++编码指南,我制作了一张比較全面的说明图,能够在短时间内高速掌握规范的重点内容.只是规范毕竟是人定的,记得活学活用.看图前别忘了阅读以下三条 ...
- PEP 8 – Style Guide for Python Code
原文:PEP 8 – Style Guide for Python Code PEP:8 题目:Python代码风格指南 作者:Guido van Rossum, www.yszx11.cnBarry ...
随机推荐
- xml文档解析
XML文档解主要分为四种解析方式,官方提供的两种分别是:DOM 和 SAX,第三方分别是:JDOM 和 DOM4j 测试用的xml文档: <?xml version="1.0" ...
- JavaScript 基础第二天
一.前言 感觉昨天的内容确实是有点细碎.复杂.感觉是没有书上写的那么的细致而且有导入性,但是我还是喜欢这样只说干货.今天的内容将继续接着昨天最后的内容JS中的语言结构继续讲解并且重点讲解一下其中的内容 ...
- Spring 使用JSTL标签显示后台数据
1. 先上项目结构图,其中config包下的代码文件参见前一篇博客 http://www.cnblogs.com/njust-ycc/p/6123505.html 引包: 2. 主要代码 (1)U ...
- python输入输出
python 如何读取控制台输入的数据 比方说:从控制台读一个人的名字,赋给变量name 如下: name = input("name:") print(name) 如何读取一 ...
- 理解一下单片机的I2C和SPI通信
应某位网友要求,今天说一下单片机的I2C SPI通信,可能说不清楚,因为这毕竟要做实验才可完全理解. I2C和SPI是两种不同的通信协议. 听到协议,似乎高不可攀,其实协议就是人们定义的一个标准而已, ...
- ABP框架详解(八)动态ApiController的生成和访问机制
在ABP框架中提供了一套动态生成ApiController的机制(依然支持原生ApiController的使用方式),虽然说是动态生成ApiController但是实际上并没有真正在启动程序的时候生成 ...
- nginx.conf各参数的意义
搬运+翻译至 http://qiita.com/syou007/items/3e2d410bbe65a364b603 /etc/nginx/nginx.conf 记录各个参数的意义 user user ...
- 高性能网站架构设计之缓存篇(1)- Redis的安装与使用
一.什么 Redis REmote DIctionary Server,简称 Redis,是一个类似于Memcached的Key-Value存储系统.相比Memcached,它支持更丰富的数据结构,包 ...
- C#中的线程四(System.Threading.Thread)
C#中的线程四(System.Threading.Thread) 1.最简单的多线程调用 System.Threading.Thread类构造方法接受一个ThreadStart委托,改委托不带参数,无 ...
- 分享一些Hadoop环境搭建所用到的软件
本来想用土的掉渣的语言说说hadoop配置的,因为最近总有人问我,环境搭建老出莫名其妙的问题,可是写到一半,还是决定不写了,网上教程好多好多,而大家遇到问题有很多是软件版本不对应造成的,因此我就把大家 ...