1.
The function is finished when the late binding runs.
Class Point
{
Public
Virtual double area () {}
...
}
Class Circle:public Point
{
Public
Double area () {}//is still a virtual function and cannot be written when redefined
}
Double CalcArea (Point &ref) {}
The program runs a member function that invokes the object based on the object referenced by ref.
A virtual function cannot be a friend, a static function, not an inline, constructor. It can be a destructor.
2.
Pure virtual function:
virtual function type function name () = 0;
Each derived class then re-defines these virtual functions as required.
Abstract classes (with at least one pure virtual function) can only be used as the base class for other classes, cannot create objects, and abstract classes may define ordinary functions.
3.
Friend £ º
Class Date;
Class Clock;
Class Clock
{
Public
friend void Display (Clock &);
}
Class Date
{
Public
friend void Clock::D isplay (Date &);
}
You can also friend class:
Friend class name;
4.
Static Members:
static int sum;
static int Display ();
It is shared for all objects of the class, opening up space outside of all objects, even if the object is not defined, and also allocates space (at compile time).
Static member initialization:
Data type class Name:: static data member name = initial value;
Can no longer be initialized in a class declaration.
Static member functions cannot access non-static members of this class by default, without the this pointer.
Access method:
Class Student;
Student S1;
Student::sum;
or s1.sum;
Polymorphism, friend and static member basic knowledge summary