Note that there are some explanatory texts on larger screens.

plurals
  1. POUndefined reference to static member function of Singleton class
    primarykey
    data
    text
    <p>I implement Singleton class for logging. I declare static of <code>logging_instance_</code> for create only one instance on class name <code>support_service::logging_service</code>. Service_logging call instance of class <code>support_service::logging_service</code> which declear static variable <code>::logging_instance_</code> but show an error</p> <p><code>undefined reference to `support_service::logging_service&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, int&gt;::logging_service()' collect2: ld returned 1 exit status</code> </p> <p><strong>support_service.hpp</strong></p> <pre><code>namespace support_service { template&lt;typename PATH = std::string , typename LEVEL = int&gt; class logging_service { public: static boost::shared_ptr&lt;logging_service&lt;PATH,LEVEL&gt; &gt; instance(); .... private: logging_service(); logging_service(const logging_service&lt;PATH,LEVEL&gt;&amp;); static boost::shared_ptr&lt;logging_service&lt;PATH,LEVEL&gt; &gt; logging_instance_; }; } template&lt;typename PATH, typename LEVEL&gt; boost::shared_ptr&lt;logging_service&lt;PATH,LEVEL&gt; &gt; logging_service&lt;PATH,LEVEL&gt;::instance() { if(logging_instance_.get() == NULL) logging_instance_ = boost::shared_ptr&lt;logging_service&lt;PATH,LEVEL&gt; &gt;(new logging_service&lt;PATH,LEVEL&gt;``()); return logging_instance_; } </code></pre> <p><strong>service_logging.hpp</strong></p> <pre><code>using namespace support_service; template&lt;typename PATH, typename LEVEL&gt; boost::shared_ptr&lt;logging_service&lt;PATH,LEVEL&gt; &gt;support_service::logging_service&lt;PATH,LEVEL&gt;::logging_instance_; namespace service_logging { template&lt;typename PATH = std::string, typename LEVEL = int&gt; class service_logging { public: service_logging(); bool set_logging(PATH file_path); }; } template&lt;typename PATH, typename LEVEL&gt; bool service_logging&lt;PATH,LEVEL&gt;::set_logging(PATH file_path) { boost::shared_ptr&lt;logging_service&lt;PATH,LEVEL&gt; &gt; logging_ = logging_service&lt;PATH,LEVEL&gt;::instance(); ... } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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