//basic syntax for abstract classes#include <iostream>using namespacestd;/*Description of multi-inheritance The fact that multiple inheritance in the real sense is abandoned by the actual development experience in the multi-inherit engineering development is almost not used multiple inheritance brings more code complexity than it brings convenience multiple inheritance has a disastrous effect on the maintainability of the Code, Any multi-inheritance can be replaced by a single inheritance. Most object-oriented languages do not support multiple inheritance the concept that most object-oriented languages support interfaces The concept of C + + does not have an interface in C + + can use pure virtual function to implement interface class only function prototype definition, no data definition. Summary: The analog interface class in C + + defines 3 conditions 1. Only public access (because subclasses must be required to override parent-class pure virtual functions) 2. You can only define function prototypes and do not provide implementations 3. Cannot define any member properties of the Analog interface class in C + + Features 1. You cannot define an interface class object 2. You can define a pointer and reference 3 for an interface class. The interface class must be pure virtual function, not virtual function pure virtual function and virtual function difference pure virtual function: virtual void P Rint () = 0; virtual function: virtual void Print () {cout<< "I am the ordinary virtual function" <<ENDL;} Pure virtual function does not have function implementation, virtual function has practical engineering experience proves that multiple inheritance interfaces do not bring about two semantics and complexity multiple inheritance can be done by carefully designing a single inheritance and interface instead of an interface class is just a function description, not a feature implementation. Subclasses need to define feature implementations based on functional descriptions. */classpoint{ Public: Virtual voidPrint () =0;};classPointa: Publicpoint{Virtual voidPrint () {cout<<"I'm a subclass. I rewrote the pure virtual function of the parent class"<<Endl; }};voidPROTECTB () {//Point p1; Error C2259: ' point ': cannot instantiate abstract classPoint *P1 =NULL; Pointa PA; P1= &PA; //Generate polymorphicP1->Print ();}voidMain () {PROTECTB (); System ("Pause");}
C + + abstract class Two (basic syntax for abstract classes)