When writing callback functions in Java, it is convenient to declare and implement the callback interface with interface.
The C + + declaration callback interface can declare a pure virtual class.
What is a pure virtual class.
A: A pure virtual class is a class that has only declarations that are not implemented.
Such as
Class Ainterface
{
virtual void fun () = 0;
}
Note: virtual void fun () = 0; is a declaration fun is a pure virtual function. If there is no = 0, then fun is just a virtual function, i.e.
Class Ainterface
{
virtual void fun ();
This class cannot be called a pure virtual class.
So
Class Ainterface
{
virtual void fun ();
} (Error-declaring method when implementation is not written)
And
Class Ainterface
{
virtual void fun () = 0;
What's the difference? (at present, the niche only encounters the following problem, so it can only talk so much.) )
Declare a virtual class instead of a pure virtual class in a. h file, and the virtual function needs to have an implementation, otherwise the error prompt for "unresolved external" "" is present at link.
To modify the method:
If the virtual class does not write the implementation, the following method declaration will not have this error
Class Ainterface
{
virtual void Fun () {};
(the method is declared correctly when the implementation is not written)