C + + 's function pointer (function pointer) is called indirectly by a pointer to a function. It is believed that many people use more of the function pointers to the general function, while the function pointer to the class member function is quite
A static member function is a member function of a class that does not belong to any object of the class request, but is a function shared by all members of that class.For example, you have 10 people in your class (10 for Class one by one), and the
Sometimes, due to the design needs, we usually need to start a class member function in the thread mode, and the most common implementation methods are two: 1. directly declare the member function as static, so that functions such as CreateThread
In the C + + class definition, you can see a definition similar to the following:class List {private: * p_head; int length; ...... Public: intconst; BOOL Getnodeinfo (constintconst {...} BOOL Deletenode (constint index);
A const member function, which can read the data members of a class, but cannot modify the data members of the class.1 statementAfter the parameter list declared by the member function, add the CONST keyword, declare it as a constant member function
1. Destructors1. Destructors have no arguments and cannot be overloaded, so a class can have only one destructor. If the user does not have a definition, the compiler will generate it automatically. 2. static The local object is not destroyed at the
1 General class static member functions cannot call non-static member functions2 can a static member function call a constructor?The answer is yes, because the static member function does not have this pointer, the general static member function
In fact, all threads are used to process C functions, rather than C ++ class member functions. The standard library provides an API function. This function uses the callback function pointer as the thread's Execution Code and calls the callback
In this regard, let me begin by saying something about:The callback function must be a static member function or a global function to implement a callback function, presumably because a normal C + + member function implies a function parameter, the
ObjectiveC + + member functions are divided into static functions, non-static functions and virtual functions three kinds, in this series of articles, many mentions static and non-static does not affect the memory occupied by objects, and virtual
Objective
C + + member functions are divided into static functions, non-static functions and virtual functions three kinds, in this series of articles, many mentions static and non-static does not affect the memory occupied by objects, and virtual
Static member features
Static member functionsNo this pointer.
Static member functionsCannot be declared as Const.
Static member functionsCannot be declared as a virtual function.
Static member functionsYou can directly access static
C + + Primer learning note _26_ operator overloading and conversion (1)--overload/non-overloaded operator, member function mode overload, Friend function mode overloadIntroduction:Use operator overloading wisely to make the use of class types as
Can I call delete in a member function of a class This? The answer is yes, it can be called, and many older libraries have this code. Suppose this member function name is release, and delete this is called in this release method, then this object
Class member function pointers:Used to access class member functions, which differ from general function pointers.A class member function handles a class data member, declaring a class member function pointer at the same time, and also pointing out
As mentioned in the previous article, inline member functions can be defined in two ways: one is to define them directly within the class body, and the other is to define the class in vitro. The following code is used:
The first definition method:
An operator overload is essentially a function overload that overloads the member function, and it is free to access the data members of this class, and when actually used, accesses the overloaded operator through an object of that class. If the
The reason for making a member private or protected is to restrict access to it, right? The exhausting compiler requires a lot of effort to ensure that the access restrictions you set are not broken, right? Therefore, it doesn't make much sense to
When referring to pointers, we generally think that it is a 8-byte object that can be represented by the void * pointer on the x86_64 architecture. For example, Wikipedia has an article on x86_64 that reads:Pushes and pops on the stack is always in 8
the class's member function is followed by a const, which indicates that the function does not make any changes to the data members of the class object (accurately, non-static data members) .When designing a class, one principle is to add a const to
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.