Sadly, this class took the laptop out of power t^t
Causes no line of Code, Sorry
The notes are as follows:
1Shape * p1;//ways to create objects using pointers2p =NewCircle (2.0);3Shape *P2;4p =NewRectangle (3.0,5.0);5 6 classShape {7 Public:8 Virtual DoubleArea () =0;//Pure virtual function9 }Ten One //Warning: Pure virtual functions cannot be defined in an introverted form, but can only be defined outside of a class A - //If there is no virtual function defined in the abstract base class, it is not possible to define it in its derived class . - the //C + + object layout - //concept: The space occupied by member functions is not in the object, but in the code snippet - - emptyclass es; +cout <<sizeof(es);//output is 1, non-empty, i.e. only the address of the ES object exists - + //1. C + + assigns virtual function table (Vtable) to each class that contains virtual functions A //2. Create a virtual pointer for each of its objects at - //override overrides: There are virtual functions in the base class that are re-implemented in the derived class, as are the return value types - //Overload overloading - //namebinding Hidden: a function defined in a derived class hides all functions of the same name in the base class - //to recover hidden methods - in intx = D4. Base::f ();//to implement indirect access to hidden virtual functions, so-called hiding is just a direct access to the hidden - to //in constructors, destructors use virtual functions that only invoke implementations of this class + //when a virtual function is used in a non-static member function, the overridden version of the virtual function is called - //because there is no this pointer in a static member function the * //RTTI: Run-time type identification, based on virtual function principle $ Runtime Type indentificationPanax Notoginseng -#include <typeinfo>//header files that need to be imported the +typeID ()//gets the actual type of the current object A typeid (BR). Name () the + //Multiple Inheritance - $ classDog: PublicPet, PublicAnimal { $ - }; - the //dynamic_case: Downward type conversion - WuyiDog * pd = Dynamic_case <dog *>(p); the - //1. If the type of P is a Dog * type, then PD = P Wu //2. Otherwise, PD = NULL is null - About //for pointers or references only, defines a virtual function in a pointer class, which must be a polymorphic class
Object-Oriented Programming-c++ inheritance & Multiple Inheritance & RTTI "13th class notes"