C++11 inheritance Constructs
#define_crt_secure_no_warnings#include<iostream>#include<string>#include<vector>#include<map>//C + + 11 allows derived classes to inherit the constructor of the base class (except the default constructor, copy constructor, move constructor). /*Note: Inherited constructors can only initialize member variables in base classes, cannot initialize member variables of derived classes if the constructor of the base class is declared private, or if the derived class inherits from the base class, the constructor cannot be inherited once the inheritance constructor is used, the compiler no longer generates a default constructor for the derived class */classa{ Public: A (inti) {std::cout <<"i ="<< I <<Std::endl;} A (DoubleDinti) {} A (floatFintIConst Char*c) {}// ...};classD | Publica{ Public: usinga::a;//Inheritance Constructors// ... Virtual voidExtrainterface () {}};voidmytest () {return;}intMain () {mytest (); System ("Pause"); return 0;}
C++11 inheritance Constructs