[C ++] functions and functions

Source: Internet
Author: User

[C ++] functions and functions
Every language will encounter a function, which is something that implements a specific function. Different languages may have different functions, but the abstract concept is basically the same. According to Mr. Mi's idea, the branches of multiple knowledge points are connected to each other, so that the knowledge can be connected to Reduce Dispersion and high cohesion. When I look at the function chapter, I first read it roughly, And then I always think about whether there is any connection between the front and back. Because of this awareness, we have found many connections. Link knowledge points, some are comparison, and some are inheritance and development.

The definition, declaration, and call of a function are a coherent process. If there is no definition, we will not be able to talk about it. Note that the features of the Function body are also defined. After a function is called, it is time to execute the function. The running process of the function body describes two calls, namely nested call and recursive call. nested call is required for indirect call of recursive call.

A function is an abstract concept. According to different functions, it has many categories and different names, such as inline functions and functions with default parameters, in the function chapter, I will give a brief introduction. When writing a C ++ program, we will write the header file, which is actually a function provided by the C ++ system.

Functions are not static. To improve efficiency, people will come up with other methods. Function overloading and function templates are proposed for convenience, while restrained functions are also designed to improve development efficiency. Restrained functions need to weigh the conflicts between time and space overhead to achieve the best effect. To some extent, function templates simplify function overloading. When talking about function overloading, you have to mention binding, which is a process related to calling. The priority of binding is the focus of function overloading.

We can see from the figure that there are many connections, and this is only the internal connection of this chapter. If you contact the whole book, when you think of a knowledge point, the whole book is equivalent to going through it. This learning method changes the learning efficiency. Relationships are everywhere, as long as you look for them carefully.




C language functions

This is my improved algorithm:
You have run any tests on the machine. All tests are successful! Haha

Void BubbleSort (int r [], int n) // array name and number of elements
{
Int t, exchange, bound;
Exchange = n; // The first Bubble Sorting range: From a [1] to a [n]
While (exchange)
{
Bound = exchange; // determines the range of a sort.
Exchange = 0; // an exchange that is assumed to have no records before the bubble sort
For (int j = 0; j <bound; j ++)
If (r [j]> r [j + 1])
{
Int t = r [j + 1];
R [j + 1] = r [j];
R [j] = t;
Exchange = j; // record the position of each exchange to determine the range of the next sort
}
}
Return;
}

How do I describe functions in C language?

Reason and role of the statement:
The C language compilation system is compiled from top to bottom. if a sub-function (User-Defined Function) is placed after the main function, the declaration should be made before it. otherwise, C compilation systems from top to bottom won't be recognized.
Simple Example:
# Include <stdio. h>
Int fun (int x, int y); // statement for subsequent function declaration -------------------
Main () |
{Int a, B, c; c = fun (a, B); printf ("% d", c) ;}|
Int fun (int x, int y) <------------------------------------
{Int z; z = x + y; return z ;}
Statement format:
[Return type] function name (parameter 1 type parameter 1, [parameter 2 type parameter 2 ,......]);
Note the last semicolon, because this is a statement

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.