If your compiler supports C++11 standard, there is a constructor inheritance using using
(pun intended). For more see Wikipedia C++11 article. You write:
class A { public: explicit A(int x) {} }; class B: public A { using A::A; };
This is all or nothing – you cannot inherit only some constructors, if you write this, you inherit all of them. To inherit only selected ones you need to write the individual constructors manually and call the base constructor as needed from them.
Historically constructors could not be inherited in the C++03 standard. You needed to inherit them manually one by one by calling base implementation on your own.
Related Posts:
- Inheriting constructors
- cannot declare variable ‘’ to be of abstract type ‘’
- QltAW.png
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- What is the difference between g++ and gcc?
- g++ ld: symbol(s) not found for architecture x86_64
- What does the explicit keyword mean?
- Struct Constructor in C++?
- C++ struct constructor
- Convert char to int in C and C++
- What does the explicit keyword mean?
- Undefined reference to vtable
- Expected initializer before function name
- Undefined reference to vtable
- C ++ error: a expected initializer before [function name]
- how to define -std=c++11 as default in g++
- C++ error: no matching constructor for initialization of
- undefined reference to ‘std::cout’
- no default constructor exists for class
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- MinGW: “gcc is not recognized as an internal or external command”
- Compiling a C++ program with gcc
- gcc/g++: “No such file or directory”
- error: use of deleted function
- CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
- Getting error: ISO C++ forbids declaration of with no type
- How to call a parent class function from derived class function?
- Error: No instance of constructor matches the argument list
- expected constructor, destructor, or type conversion before ‘(’ token
- Debug vs Release in CMake
- Debug vs Release in CMake
- C++ template constructor
- What is object slicing?
- expected identifier before string constant
- Why is inherited member not allowed?
- What does the fpermissive flag do?
- gcc: undefined reference to
- Update GCC on OSX
- Creating an instance of class
- GCC -fPIC option
- In C++ can constructor and destructor be inline functions?
- When is it safe to call this-> in constructor and destructor
- Class template inheritance C++
- gcc -g :what will happen
- Warning : overflow in implicit constant conversion
- C++ Cannot call constructor directly in small example
- cc1.exe System Error – libwinpthread-1.dll missing – But it isn’t
- Struct inheritance in C++
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- C++ calling base class constructors
- How to Check the Version of my gcc?
- Make / gcc cryptic error 2: how to have more information?
- Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file
- Sleep for milliseconds
- C++ Cout & Cin & System “Ambiguous” [closed]
- undefined reference to `WinMain@16′
- How can I clear console
- How to go from fopen to fopen_s
- How does the modulus operator work?
- What exactly is std::atomic?
- Separating class code into a header and cpp file
- Deep copy vs Shallow Copy
- Pointer to incomplete class type is not allowed
- How to write C++ getters and setters
- std::out_of_range error?
- Checking cin input stream produces an integer
- Why do C++ objects have a default destructor?
- Where do “pure virtual function call” crashes come from?
- How to get current timestamp in milliseconds since 1970 just the way Java gets
- What is the best open XML parser for C++?
- *** No rule to make target ‘class.cpp’, needed by `build/….x86/class.o` Stop. error in Ubuntu
- What’s the difference between opening a file with ios::binary or ios::out or both?
- Hash function for a string
- How to run valgrind with basic c example?
- initial value of reference to non-const must be an lvalue
- Strange error C2131: expression did not evaluate to a constant in VC 2015
- error: called object type ‘int’ is not a function or function pointer
- Hash function for a string
- Is there a replacement for unistd.h for Windows (Visual C)?
- Double pointer array in c++
- Don’t understand static boolean behavior
- How to write std::string to file?
- Member declaration not found
- What is the difference between a .cpp file and a .h file?
- Stable Cotangent
- How to change string into QString?
- Including .cpp files
- Function call missing argument list to create pointer
- cannot specify explicit initializer for arrays
- What does ** mean in C++?
- Incomplete type is not allowed: stringstream
- Initializing default values in a struct
- Warning: comparison of distinct pointer types
- Two decimal places using printf( )
- error C2244 unable to match function definition to an existing declaration
- clearing a vector of pointers [duplicate]
- Evaluate a string with a switch in C++ [duplicate]
- C++ JSON Serialization
- stack around the variable…was corrupted
- Creating a list to hold objects in C++