C ++ introduction source code Concise version, C ++ entry-level C ++ learning, the difference between C ++ and C is worth knowing, the source code is known

Source: Internet
Author: User

C ++ introduction source code Concise version, C ++ entry-level C ++ learning, the difference between C ++ and C is worth knowing, the source code is known

C ++ introduction source code brilliant version, C ++ entry-level C ++ learning, the difference between C ++ and C is worth knowing

Basic differences between C language and C ++

C ++ Standard Input and Output

Name blank

1. namespace definition:

Namespace identifier {} example: namespace my {int a = 1 ;}

Member access in the namespace: Scope identifier: cout <my: a <endl;

Omit the qualifier (prefix): using namespace my;

Think of the standard namespace: using namespace std; the standard namespace does not have this, you need to add std: cout, std: cin, std: endl;

2. Nesting of namespaces:

Cout <my: danny: B <endl; do not want to use such a long prefix

1: using namespace my: danny;

2: namespace IM = my: danny

Bool: Boolean Type

1. Values: 0, 1, false, and true

2. true and false. Non-zero in the computer indicates true. Only 0 indicates false.

3. Memory occupies 1 byte

Generally used to determine the type of return value of a function

Reference Type

1. Alias Function

2. prevent the generation of copy books

3. Use it as the left Value

4. Reference of the right value: constant reference example: int A (int & mm); A (1) can be used during call );

Heap memory Application

Changed from malloc, realloc, calloc, and free to new and delete.

Struct:

1. Define variables and use struct names directly. The keyword struct can be omitted.

2. The existence of members allowed in the struct and the existence of the constructor

Inline

The inline keyword is used to define an inline function of a class. The main reason for introducing it is to use it to replace the macro definition in expression form in C.

Function overload

Function overload: Allows functions with the same name and different parameters to exist.

1. Different parameter numbers

2. Different parameter types

3. Different parameter types

Function default

Function default: Allows function parameter initialization.

1. The default function is actually an optimization body of overload.

2. The default function must start from right to left.



  • This article has been included in the following columns:

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.