2. process-oriented programming

Source: Internet
Author: User

1. Write Functions

Declare before calling

2. Call a function

Function parameter value passing includes value passing reference passing pointer passing

3. The function provides default parameters.

Void fun (vector <int> & VEC, ofstream * ofil = 0)

The default value starts from the right side. If a function parameter has a default value, all its right parameters have a default value.

Raise the visibility. The default value is placed at the function declaration, not the definition.

4. Use a local static object

Void fun {

...

Static vector <int> VEC;

...

}

Defining static objects outside a function is an adventure to save the communication problem between functions. It will disrupt the independence between different functions and make them hard to understand.

5. inline functions

The Inline Function indicates that the compiler expands the function content on each function call point. (The compiler replaces the call operations of functions with one-to-one copy of the function code to improve efficiency.) it can be understood as a Java static function.

6. Overload Functions

Different parameters (parameter quantity, parameter type) have the same name

7. template Functions

Template <typename elemtype>

Void fun (vector <elemtype> vect ){

}

8. function pointer pointers to Functions

Const vector <int> * (* fun_ptr) (INT size );

9. header files)

Extension. h standard library exceptions

Function Definition and Declaration

Only one copy can have multiple declarations

The inline function is defined in the header file.

Objects modified by extern (except const object) are as follows:

Const int seq_cnt = 6;

Externconst vector <int> * (* seq_array [swq_cnt]) (INT); // non-const object is a pointer

Include

Include "numseq. H" header file provided by the user

Include <vector> standard header file

2. process-oriented programming

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.