You need to do the second. Delegating constructors only works in the constructor’s initialization list, otherwise you’ll just create a temporary or do other mistakes like you mentioned.
Related Contents:
- What is the difference between ‘typedef’ and ‘using’ in C++11?
- Compiling C++11 with g++
- What are inline namespaces for?
- Which kind of pointer do I use when?
- Undefined reference to static constexpr char[]
- How do I typedef a function pointer with the C++11 using syntax?
- Should I use virtual, override, or both keywords?
- Check if a class has a member function of a given signature
- How can I pass std::unique_ptr into a function
- Is 1.0 a valid output from std::generate_canonical?
- Removing item from vector, while in C++11 range ‘for’ loop?
- How to get duration, as int milli’s and float seconds from ?
- Is there a non-atomic equivalent of std::shared_ptr? And why isn’t there one in ?
- Do rvalue references to const have any use?
- What is the purpose of std::function and how to use it?
- How do I combine hash values in C++0x?
- Why no default move-assignment/move-constructor?
- C++11 make_pair with specified template parameters doesn’t compile
- Why does std::array not have an constructor that takes a value for the array to be filled with?
- Converting std::__cxx11::string to std::string
- C++11: Correct std::array initialization?
- Is unique_ptr guaranteed to store nullptr after move?
- C++11 “auto” semantics
- How can I have multiple parameter packs in a variadic template?
- How to update GCC in MinGW on Windows?
- GCC worth using on Windows to replace MSVC?
- Correct usage of rvalue references as parameters
- Convert a vector to initializer_list
- Are there downsides to using std::string as a buffer?
- How do “acquire” and “consume” memory orders differ, and when is “consume” preferable?
- Why can’t clang with libc++ in c++0x mode link this boost::program_options example?
- Move constructor on derived object
- Get time since epoch in milliseconds, preferably using C++11 chrono
- Why are std::shuffle methods being deprecated in C++14?
- Dynamic casting for unique_ptr
- In C++11 is sqrt defined as constexpr?
- Difference between steady_clock vs system_clock?
- C++11 static_assert and template instantiation
- Set std::vector to a range
- Moving a member function from base class to derived class breaks the program for no obvious reason
- Why does std::declval add a reference?
- Function that accepts both lvalue and rvalue arguments
- Why can’t we have automatically deduced return types?
- C++ std::unique_ptr return from function and test for null
- Lock-free swap of two unique_ptr
- Which std::async implementations use thread pools?
- What is the partial ordering procedure in template deduction
- “to_string” isn’t a member of “std”?
- Cohabitation of boost::shared_ptr and std::shared_ptr
- Documenting enum values with doxygen