#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
int main()
{
double degrees, radians;
const double PI = 3.14159;
cout << "Enter an angle in degrees and I will convert it\n";
cout << "to radians for you: ";
cin >> degrees;
radians = degrees * PI / 180;
cout << degrees << " degrees is equal to ";
cout << fixed << showpoint << setprecision(4);
cout << left << setw(7) << radians << "radians.\n ";
return 0;
}
编译时,我遇到多个与未声明的操纵器有关的错误,但我在#include指令的顶部。但是,如果我仅使用namespace:std替换了using std ::行,则代码运行良好。
答案 0 :(得分:4)
setw
,fixed
,setprecision
和left
也在std
命名空间中,因此您需要添加using
指令全部都是。