1 normal function: is a global function, not restricted by specific classes and objects, can be called directly.
For example:
void printf ()
{
printf ("Hello World");
}
2 Ordinary member function: C + + Normal member function is essentially a generic function that contains the this pointer to a specific object, that is, the normal member function of the C + + class implicitly contains a this pointer to the current object.
For example: Define a class:
Class MyClass
{
Public
void Myprint ()
{
printf ("m_a:%d", m_a);
}
Private
int m_a;
};
void Main ()
{
MyClass A1 (5);
A1.myprint ();
}
Call the normal member function inside the main function: A1.myprint () is equivalent to Myprint (&A1). This is because the C + + compiler implements ordinary member functions, the nature of Void Myclass::myprint () is the ordinary function void Myprint (MyClass *this);
3 Static member functions
First, the static member variable of a class is introduced: The data member in the class body is preceded by the static keyword, and the data member becomes the static data member of the class.
The nature of static member variables:
1 The static variable is initialized only once, and the next execution of the initialization statement is skipped directly.
2 Static Description A member of a class is a statically member, the member variable modified by static belongs to this class, no longer only belongs to the specific object.
Again, static member functions: the declaration of a member function in a class body, preceded by the static keyword, becomes a static member function of the class.
The nature of static member functions:
1 non-static members of the class can not be invoked.
2 static member functions do not contain this pointer. A static member function belongs to this class and is no longer just a specific object.
Therefore, the difference between a static member function of a class and a normal member function of a class is:
A static member function does not contain this pointer to a specific object;
The normal member function contains a this pointer to a specific object.