Basic----functions for C + +

Source: Internet
Author: User

The top-level const is ignored when an argument is initialized with an taxiing parameter.

Use constant references as much as possible, and ordinary references can limit the types of arguments that can be accepted and mislead callers.

3 Ways to manage array arguments:
    • The array itself contains a closing tag
    • Passing pointers to the elements of the array
    • Defines a formal parameter that represents the size of an array

Functions of deformable parameters

If the argument type is the same, the Initializer_list template type is available, and the variable parameter template is used if the type is different.

The initialization list supports size () begin () end (), and copies and assignments do not copy elements, but are shared.

Returns an array pointer

typedef int ARRT[10];

Using ARRT=INT[10];

arrt* func (int i);

Declaring functions without type aliases

int (*func (int i)) [10];

Using the tail return type

Auto func (int i), int (*) [10];

Using Decltype

Const overload

The top-level const does not differentiate, so it cannot be overloaded

The underlying const can be overloaded, and a const object can only be passed to a const parameter, whereas a very high-level object compiler takes precedence over a very heavy version.

ASSERT (expr) ndebug

When it is true, do nothing; export the information at the time of the false and terminate the execution of the program.

Dependent on the state of the Ndebug preprocessing variable

Ndebug can also be used to write debug code

Several useful variables that are defined by the compiler

__FUNC__ the name of the currently debugged function const char Array

__file__ string literals for storing file names

__line__ integer literals that hold the current line number

__time__ string literals that store file compilation time

__date__ string literals that store file compilation dates

Basic/C + +----functions

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.