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
- Is “delete this” allowed in C++?
- What is a segmentation fault?
- How many spaces for tab character(\t)?
- How to create a dynamic array of integers
- How to create a dynamic array of integers
- Linker Error C++ “undefined reference ” [duplicate]
- How do I build a graphical user interface in C++? [closed]
- C++ convert from 1 char to string?
- How do I build a graphical user interface in C++? [closed]
- convert a char* to std::string
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- system(“pause”); – Why is it wrong?
- Pause Console in C++ program
- How to implement 2D vector array?
- Why the switch statement cannot be applied on strings?
- How to use setprecision in C++
- How to dynamically allocate arrays in C++
- What does (~0L) mean?
- How to dynamically allocate arrays in C++
- What is the best way to use a HashMap in C++?
- What is the best way to use a HashMap in C++?
- What are the differences between a pointer variable and a reference variable in C++?
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- Sleep for milliseconds
- How to convert string to char array in C++?
- How can I convert a std::string to int?
- Easiest way to convert int to string in C++
- What is the difference between float and double?
- Why is “using namespace std;” considered bad practice?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- outputting ascii table in C++
- What is a lambda expression in C++11?
- Vector of Vectors to create matrix
- How to throw a C++ exception
- std::string to char*
- How to generate a random number in C++?
- pinpointing “conditional jump or move depends on uninitialized value(s)” valgrind message
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- How do I find the length of an array?
- Sleep for milliseconds
- How to convert string to char array in C++?
- C++ — expected primary-expression before ‘ ‘
- Using getline() with file input in C++
- What is the effect of extern “C” in C++?
- C++ Cout & Cin & System “Ambiguous” [closed]
- ld: symbol(s) not found for architecture x86_64 error