C++ virtual classes are equivalent to abstract classes in java. The difference from interfaces is:
1. A subclass can only inherit one abstract class (virtual class), but can implement multiple interfaces
2. An abstract class can have a constructor method, but an interface does not have a constructor method.
3. The methods in an abstract class are not necessarily abstract methods, that is, the methods in them can have implementations (with method bodies). The methods in the interface are abstract methods, and there cannot be method bodies, only declarations
4. An abstract class can be public, private, protected, and default, and the interface only has public
5. The methods in an abstract class can be public, private, protected, and default. The methods in the interface can only be public and default.
The same is: neither can be instantiated.
Additional Note: Interfaces are a special type of abstract class, a more abstract class, which you may understand in this way. An abstract class is an incomplete class, and the interface only defines some functions. For example, use abstract classes and interfaces to describe "dogs". Abstract classes add abstrict before general classes and say: "Pigs can run with limbs, pigs can run like this or that...", and the interface can only say: "Pigs can run, and what they use to run is a subclass."
The above article briefly discusses the similarities and differences between Java interfaces and C++ virtual classes. This is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.