title: In C + + singleton mode, if I modify a member variable in two member functions, will it conflict？
body: <p>In C + + singleton mode, if I modify a  member variable in two member functions, will it conflict?Do I need a mutex?</p>
  <p>for example:</p>
  <pre><code>class Teacher
  {
       int var;
       int func1(int a)
       {
           var = a;
       }
       int func2(int b)
       {
           var = b;
       }
       ...
  }
  </code></pre>
  <p>what is &quot;singleton mode&quot; in c++? I define a class to explain this question.The purpose is to make the whole program have only one object of this class.
  for example:</p>
  <pre><code>class terminal485{
  public:    
      ~terminal485();
      terminal485(const terminal485&amp;)=delete;
      terminal485&amp; operator=(const terminal485&amp;)=delete;
      static terminal485&amp; Instance(){
          static terminal485 instance;
          return instance;
      }
      void setPointer(AxesGroupRef *axes){
          if(axes != nullptr &amp;&amp; this-&gt;p_axes == nullptr){
              this-&gt;p_axes = axes;            
              printf(&quot;[%s] %p\n&quot;,__FUNCTION__,axes);
          }
      }    
  
      int recvTerminal485Message(char *readbuf);
      int getIndex();
      int getBuf(char *readbuf);
  private:
      terminal485():p_axes(nullptr), m_bufLen(0){
          printf(&quot;[%s] construct this class \n\n\n\n\n&quot;,__FUNCTION__);
      }
      AxesGroupRef *p_axes;
      Terminal485Protocol m_protocol;
      char m_recvBuf[200];
      int m_bufLen;
      std::mutex m_mutex;
  };
  </code></pre>