C++11 inheritance Constructs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.