Abstract: This section describes how to obtain the member function address and call the address.
Keyword: C ++ member function this pointer call Convention
I. Usage of member function pointers
In C ++, the pointer to a member function is special.
Standard C ++ does not have real Object-Oriented function pointers. This is a pity, because Object-Oriented function pointers (sometimes called delegates) have proved their value in other languages. In Delphi (Object-Oriented PASCAL Language),
In C + +, a pointer to a member function is a very special thing. For a normal function pointer, it can be treated as an address and can be arbitrarily converted and called directly when needed. However, for member functions, general type
Member function pointers and high-performance
C ++ delegation (Part 1)
Member function pointers and the fastest possible C ++ delegates
Author:
Don Clugston
Translation: Zhou Xiang
Introduction
Standard
C ++ does not have a real
C + + static member functions
Like a data member, a member function can also be defined as static, and the preceding addition of a function in a class becomes a static member function. Such as
static int volume ();
As with static
4.4 Pointer to Member function (Pointer-to-member Functions)take a nonstatic data member address, the result is the member in the class layout of the byte position (plus 1), it is an incomplete value, need to be bound to the address of a class
4.4 Pointer to Member function (Pointer-to-member Functions)take a nonstatic data member address, the result is the member in the class layout of the byte position (plus 1), it is an incomplete value, need to be bound to the address of a class
The C language pointer is quite flexible, but it is also quite easy to make mistakes. Many C-language beginners, even the C-language veteran, are apt to stumble under the C-language pointer. But there is no denying that the position of the pointer
In fact, we can intuitively understand that static member functions cannot invoke non-static member variables.Because both static member functions and static member variables are in the category of classes, andThere is always only one copy of the
Call of member functions such as C ++ vs call of common functions
First, see the following statement:
Point3d obj;Point3d *ptr = &obj;
When the above pointer or object is used to call the member function Func (), there will
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.