title: Expected primary expression before '.'
body: <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  using std::cout;
  using std::endl;
  
  class square {
  
  public:
      double length, width;
      
      square(double length, double width);
      square();
      
      ~square();
      
      double perimeter();
  };
  
  double square::perimeter() {
  return 2*square.length + 2*square.width;
  }
  
  int main() {
  
  square sq(4.0, 4.0);
  
  cout &lt;&lt; sq.perimeter() &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>
  <p>I'm trying to write a simple class program. I am getting the error</p>
  <pre><code>in member function 'double square::perimeter()';
  .cpp:21: error: expected primary-expression before '.' token
  .cpp:21: error: expected primary-expression before '.' token
  </code></pre>
  <p>Does this mean I have to use <code>2*square::length + 2*square::width</code>?</p>