c++ why definition of static member is not always required?
<p>I read this good <a href="http://stackoverflow.com/questions/7092765/what-does-it-mean-to-have-an-undefined-reference-to-a-static-member">post</a> (on undefined-reference-to-a-static-member), but i from what i can see i dont always required to defined the static member in the cpp. So i am asking for help to understand the rules.</p>

<p><strong>several examples - all examples without def in the cpp.
In the h file for class Master declaration is :</strong></p>

<pre><code>class Master{
public:
    static IDataSynchronization&amp; sync_data_cb_;
}
</code></pre>

<p><strong>In cpp:</strong></p>

<pre><code>void Master::start(IDataSynchronization&amp; syncDataCB);   - error for undefined
void Master::start(int p,IDataSynchronization&amp; syncDataCB);  no error
</code></pre>

<p>//Here is use in the static sync_data_cb_
    void Master::sendData(){
        list data  = sync_data_cb_.syncData();
        list::iterator it;
        for (it = data.begin(); it != data.end(); ++it) {
    sendto(instance_->data_sock_fd_, (*it).c_str(), (*it).length(), 0,(const struct sockaddr *) &amp;instance_->target_host_data_, instance_->sockadd_length_);</p>

<pre><code>    }
}
</code></pre>

<p>for this class:</p>

<pre><code>class Logger {
public:
    static void Log(const char *format, ...);
private:
    static FILE* file_;
    static mutex mtx_;
};
</code></pre>

<p>If in another classes that i declared static static FILE* (and used it in the class methods) i dont getting an error for undefined it.</p>

<p><strong>I am using in these static memners in all cases.</strong></p>

<p>Can anyone clear the ruled for me?</p>

<p>Thank you</p>
