I didn't know much about these three types of heavy loads some time ago. There are some mixed concepts.
Today I made an example to test the functions
Different.
Base class:
Class
{
Public:
A ();
Void F1 ();
Virtual void F2 ();
Virtual void F3 () = 0;
Virtual ~ A ();
};
Subclass:
Class B: public
{
Public:
B ();
Void F1 ();
Void F2 ();
Void F3 ();
Virtual ~ B ();
};
Main function:
Int main (INT argc, char * argv [])
{
A * m_j = new B ();
M_j-> F1 ();
M_j-> F2 ();
M_j-> F3 ();
Delete m_j;
Return 0;
}
F1 () is a common overload.
When m_j-> F1 (); is called, F1 () in Class A is called.CodeIt will be fixed.
That is, the function of this class is called as defined by Class.
F2 () is a virtual function.
When m_j-> F2 () is called, it will call the corresponding function of the stored object in m_j. This is because of the new B
Object.
F3 () is the same as F2 (), but does not need to write function reality in the base class.