1. When inheriting the base class, the base class constructor carries Parameters
Subclass Constructor (): base class (parameter), subclass Parameter
2. Function override (occurs between the parent class and the subclass)
Function overload (between classes)
3. type conversion memory matching
4. c ++ polymorphism (some of the virtual sub-classes call the parent class if they do not exist)
Pure virtual function -- virtual void breathe () = 0;
5. C ++ initialization for reference and definition (equivalent to variable alias)
Int B = 6;
Int & a = B;
6. header file pre-Compilation
# Ifndef XXX_H
# Define XXX_H
Jjjjj ()
# Endif
7. Single compilation and project Compilation
8. To be continued
============= Simple example ============
A. Polymorphism
# Include <iostream> using namespace STD; Class A {public: A () {cout <"constructor ------ A ()" <Endl ;}~ A () {cout <"destructor ------~ A () "<Endl;} void printinfo () {cout <" WYZ ------- a "<Endl ;}}; Class B: Public A {public: B () {cout <"constructor ------ B ()" <Endl ;}~ B () {cout <"destructor ------~ B () "<Endl;} void printinfo () {cout <" WYZ ------- B "<Endl ;}}; Class A1 {public: A1 () {cout <"constructor ------ A1 ()" <Endl;} virtual ~ A1 () {cout <"destructor ------~ A1 () "<Endl;} virtual void printinfo () {cout <" WYZ ------- A1 "<Endl ;}}; class B1: Public A1 {public: b1 () {cout <"constructor ------ B1 ()" <Endl ;}~ B1 () {cout <"destructor ------~ B1 () "<Endl;} void printinfo () {cout <" WYZ ------- B1 "<Endl ;}; int main () {A * A = new B (); // not a polymorphism, A-> printinfo (); cout <Endl; B. printinfo (); Delete A; cout <Endl; A1 * a1 = new B1 (); // A1-> printinfo (); Delete A1; return 0 ;}
Running result:
Constructor ------ A () constructor ------ B () wyz ------- A constructor ------ A () constructor ------ B () wyz ------- B destructor ------~ A () constructor ------ A1 () constructor ------ B1 () wyz ------- B1 destructor ------~ B1 () destructor ------~ A1 () destructor ------~ B () destructor ------~ A ()