Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Delegated Constructors With Headers
    primarykey
    data
    text
    <p><strong>Delegated Construction Question:</strong> Compiler Error C2039: '{ctor}' is not a member of Logging::LogManager</p> <p>I am using Microsoft's <em>C++ November 2012 CTP Compiler</em>, not the default one in Visual Studio 2012, so I have access to new C++ features, (variadic templates, etc).</p> <p>I am trying to get delegated construction to work using namespaces and header files... I am not certain if this falls under the base constructor inheritance features yet to be implemented in Visual Studio 2012; so, it may be the case that I shouldn't expect this to work:</p> <p>How do you do this in C++ 11?</p> <pre><code>// LogManager.h extract namespace Logging { class LogManager { private: static std::wstring defaultFileName; explicit LogManager(std::wstring logFileName); explicit LogManager(); ~LogManager(void); } // LogManager.cpp extract /******************************************************************** *****/ Logging::LogManager::LogManager(std::wstring fileName) {} /******************************************************************** *****/ Logging::LogManager::LogManager() : LogManager(defaultFileName) // Yields C2664 // : Logging::LogManager::LogManager(defaultFileName) // Yields C2039 // : Logging::LogManager(defaultFileName) // Yields C2614 {} </code></pre> <p>error C2039: '{ctor}' : is not a member of 'Logging::LogManager'</p> <p>error C2614: 'Logging::LogManager' : illegal member initialization: 'LogManager' is not a base or member </p> <p>error C2664: 'Logging::LogManager::LogManager(const Logging::LogManager &amp;)' : cannot convert parameter 2 from 'std::wstring' to 'const Logging::LogManager &amp;'</p> <p><strong>Answer::</strong> Cannot use explicit keyword in header file per known bug already known to Microsoft.</p> <p>Only the first signature will work of the Constructor will work with this .. workaround.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload