Error: Identifier "cout" is undefined. <iostream> included and using namespace std;

Error: Identifier "cout" is undefined. <iostream> included and using namespace std;

我正在尝试 cout 一些变量,但编译器说 cout is undefined。我已经包含了 iostream 并且正在使用命名空间标准。删除 using namespace stdusing std::cout 而不是将问题更改为 "namespace "std" has no member "cout" "。我发现一些答案说要将 # include "stdafx.h" 添加到代码中,但是 Error: cannot open source file "stdafx.h" 发生了。

代码是:

#include "Complex.h"
#include <cmath>
#include <iostream>

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 << real << " +_" << imag << "i" << endl;
    } else {
        cout << sqrt((real^2) + (imag^2)) << "*e^-" << atan(imag / real)<< endl;
    }
};

我正在尝试定义一个 class,所以我的 main 在别处。 运行 一个非常基本的程序,只计算 "hello world" 工作正常,问题是特定于这段代码的。

#include<iostream>放在第一位,顺序很重要

#include "Complex.h"
#include <iostream>
#include <cmath>

PS: 为什么在使用 "using namespace std;" 时使用 std::?