title: What is the difference between "::" "." and "->" in c++
body: <p>I created a class called <em><code>Kwadrat</code></em>. The class has three <code>int</code> fields. My <em>Development Environment</em> suggests that I access the fields from <em><code>Kwadrat</code></em> created objects via the <strong><code>::</code></strong> &amp; <strong><code>-&gt;</code></strong> operators. I tried both operators, and found that the <strong><code>-&gt;</code></strong> operator is able to successfully access the data in the objects fields, although, the same cannot be said for the <strong><code>-&gt;</code></strong> operator.
  I have also found that the <strong><code>.</code></strong> operator will access class members as well. I am confused, and don't understand why there are three members for accessing object members &amp;/or methods. Can someone please explain to me what the difference is between the three operators?</p>
  <hr />
  <h1>          1. <code>-&gt;</code></h1>
  <h1>          2. <code>::</code></h1>
  <h1>          3. <code>.</code></h1>
  <hr />
  <pre><code>
  
      #include &lt;iostream&gt;
  
      using namespace std;
  
      class Kwadrat{
  
      public: 
          int val1,
              val2,
              val3;
  
          Kwadrat(int val1, int val2, int val3)
          {
              this-&gt;val1 = val1; // Working
              this.val2 = val2;  // Doesn't Work!
              this::val3 = val3; // Doesn't Work!
          }
      };
  
  
      int main()
      {
          Kwadrat* kwadrat = new Kwadrat(1,2,3);
  
          cout&lt;&lt;kwadrat-&gt;val1&lt;&lt;endl;
          cout&lt;&lt;kwadrat-&gt;val2&lt;&lt;endl;
          cout&lt;&lt;kwadrat-&gt;val3&lt;&lt;endl;
  
          return 0;
      }
  
  
  </code></pre>