In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to carry out C++ function pointer content introduction, I believe that many inexperienced people are helpless, for this reason this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.
The original version of C++ evolved from a version of C called C with Class. C++ is called C++ because people want to show that it is an evolved version of C through the ++ operator of C. Today we will introduce one of the basic concepts in detail, about the specific content of C++ function pointers.
In C/C++, data pointers are the most direct and commonly used, so it is easier to understand. Function pointers, called dynamically at runtime (such as CallBack Function), are a common and useful tool.
Let's start with a brief description of C++ function pointers.
regular function pointer
void(*fp)();
fp is a typical function pointer to a function that has no arguments and no return value.
void(*fp2)(int);
fp2 is also a C++ function pointer to a function that takes an integer argument and has no return value.
Of course, experienced people generally recommend using typedef to define the type of function pointer, such as:
typedef void(* FP)(); FP fp3; //Same definition as fp above.
C++ function pointers are feared by beginners, the main reason is that it has too many brackets; some function pointers for certain purposes tend to get people trapped in brackets, not here for example, because it is not the scope of this article;typedef method can effectively reduce the number of brackets, as well as clarify the hierarchy, so recommended. For the time being, this article only considers simple function pointers, so typedef is not needed.
Suppose there are two functions:
void f1() { std::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.