我正在尝试cout一些变量,但是编译器会这样说cout is undefined。我已经包含了iostream,并且正在使用命名空间std。删除问题using namespace std,using std::cout改为将问题更改为“名称空间“ std”没有成员“ 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 << …Run Code Online (Sandbox Code Playgroud)