title: Error: Identifier "cout" is undefined. <iostream> included and using namespace std;
body: <p>I am trying to <code>cout</code> some variables but the compiler says that <code>cout is undefined</code>. I have included iostream and am using namespace std. Removing <code>using namespace std</code> and <code>using std::cout</code> instead changes the issue to "namespace "std" has no member "cout" ". I found some answers saying to add <code># include "stdafx.h"</code> to the code but <code>Error: cannot open source file "stdafx.h"</code> occurs.</p>
  
  <p>Code is:</p>
  
  <pre><code>#include "Complex.h"
  #include &lt;cmath&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  Complex::Complex(int PolarOrRectang, float RealOrArg, float ImagOrAng) {
      if (PolarOrRectang == 0) {
          real = RealOrArg;
          imag = ImagOrAng;
      else {
          real = RealOrArg * cos(ImagOrAng);
          imag = RealOrArg * sin(ImagOrAng);
      }
  };
  
  void Complex::getValue(int PolarOrRectang) {
      if (PolarOrRectang == 0) {
          cout &lt;&lt; real &lt;&lt; " +_" &lt;&lt; imag &lt;&lt; "i" &lt;&lt; endl;
      } else {
          cout &lt;&lt; sqrt((real^2) + (imag^2)) &lt;&lt; "*e^-" &lt;&lt; atan(imag / real)&lt;&lt; endl;
      }
  };
  </code></pre>
  
  <p>I'm trying to define a class, so my main is elsewhere.
  Running a very basic program that just couts "hello world" works fine, the problem is specific to this code.</p>