In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the introduction of function pointers in C++". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. let's study and learn the introduction of function pointers in C++.
Pointer to function:
A function is assigned an entry address at compile time, and the entry address of this function is called the function pointer.
The and array name represent the address type of the first element of the array, and the function name represents the entry address of the function.
The definition is as follows:
Data type (* pointer variable name) (function argument list)
Note:
1.int (* p) (int, int) means to define a pointer variable p that points to a function, which does not always point to a function, but simply means that a variable of such a type is defined, which is specially used to store the entry address of the function. In the program, the address of any function (the value of the function is integer and has two integer arguments) is assigned to it, it points to a function. In a program, a pointer variable can point to different functions of the same type one after another.
two。 When assigning a value to a function pointer variable, you only need to give the function name, not the parameter.
Such as p=max
3. When calling a function with a function pointer, you only need to replace the function name with (* p) and write the arguments as needed in parentheses after (* p).
For example: C = (* p) (aPerm b)
4. It is meaningless to perform operations on function pointer variables, such as pairing, paging, etc.
Code example:
/ / CppTest.cpp: defines the entry point for the console application. / / # include "stdafx.h" # include using namespace std;int max (int x TCHAR* argv int y); int min (int x pencil int y); int sub (int x line int y); int call (int x pen int y (* p) (int x m int y)); int _ tmain (int argc, _ TCHAR* argv []) {cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.