[c + +] Basic Ideas and Style guide

Source: Internet
Author: User

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 is required in C + +.
Variables should is defined close to theiruse.
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.

In short, forget the C language.

C + + Standard Library

For efficiency reasons, STL are not object-oriented:

      • Makes little use of inheritance, and
      • Makes no use of virtual functions

The standard Template library (STL) was a part of the C + + library, Some others is:

Category One:

    • 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

Category Two:

Containers: vector, list, stack, ...
algorithms: find, sort, copy, ...
iterators is 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

Google Open source Project style guide

The practice of language style is the best way to Learn. Understanding the Author's style of thinking, it means that language learning has reached a good standard.

The road is long ... There is no shortcut except Persistence. Good luck!

[c + +] Basic Ideas and Style guide

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.