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
- What is the effect of extern “C” in C++?
- What exactly is the difference between “pass by reference” in C and in C++?
- What is `CString`?
- Difference between != and =! with an example(in C++)
- Unresolved external symbol in object files
- How do sizeof(arr) / sizeof(arr[0]) work?
- 1e-9 or -1e9, which one is correct?
- Returning an empty string : efficient way in c++
- invalid conversion from ‘const char*’ to ‘char*’
- Evaluate a string with a switch in C++ [duplicate]
- How to get current time and date in C++?
- Class name does not name a type in C++
- Identifier not found error on function call
- Is there a tab equivalent of std::endl within the standard library?
- Using the fstream getline() function inside a class
- Missing vc_runtimeminimum_x86.msi and installation won’t work
- I’m getting an error “invalid use of incomplete type ‘class map’
- “Error: expression must have a pointer type” when using the “this” keyword
- This declaration has no storage class or type specifier in C++
- error: expected unqualified-id before ‘if’
- How to convert C++ Code to C
- how to convert C# to C++
- What are helper functions in C++?
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- C++ String Variable Declaration
- How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?
- fatal error LNK1169: one or more multiply defined symbols found in game programming
- How to initialize a vector of pointers
- C++: Using ifstream with getline();
- How to add element to C++ array?
- LINK : fatal error LNK1561: entry point must be defined ERROR IN VC++
- Comparing the values of char arrays in C++
- Win32 Console Application
- Convert char array to single int?
- https://stackoverflow.com/questions/3865946/error-generic-array-creation
- Does C++11 have C#-style properties?
- How to print a string in C++
- In c++ what does a tilde “~” before a function name signify?
- C++ Void Function with File Stream Error
- What is the best way to develop a C++ web application?
- How to install Visual Studio Build Tools 2010 on Visual Studio 2015 Community?
- Throwing out of range exception in C++
- Is null reference possible?
- Negative RGB Values
- Link error “undefined reference to `__gxx_personality_v0′” and g++ [duplicate]
- How to use bitmask?
- -Error reading characters of string