title: "cout" does not name a type error
body: <p>I am trying pure virtual function. So I have written code accordingly.
  But I ma not getting any problem because of that. I am getting "cout does not name a type" error in my code, even I have included proper header file and namespace as well.
  Please give your suggestions for this.</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  struct S {
    virtual void foo();
  };
  
  void S::foo() {
    // body for the pure virtual function `S::foo`
   cout&lt;&lt;"I am S::foo()" &lt;&lt;endl;
  }
  
  struct D : S {
    cout &lt;&lt;"I am inside D::foo()" &lt;&lt;endl;
  };
  
  int main() {
    S *ptr;
    D d;
    ptr=&amp;d;
    //ptr-&gt;foo();
    d.S::foo(); // another static call to `S::foo`
    cout &lt;&lt;"Inside main().." &lt;&lt;endl;
    return 0;
  }
  </code></pre>