在c ++中,单词oct和hex是否定义为宏?

Inv*_*tus 0 c++ c++11

我写了一个非常基本的程序,但无法理解它的行为.

     # include<stdio.h>
     # include<iostream.h>
     # include<conio.h>

     using namespace std;
     int main()
     {
       cout << "50" << oct <<"50" << hex <<"50" << abc << "50";// error abc not defined
       cout << "50" << oct <<"50" << hex <<"50"; // No error output 505050
       getch();   
    } 
Run Code Online (Sandbox Code Playgroud)

octhex定义为任何文件的一些宏,我已经包含了这就是为什么我不明白的第二错误的原因cout说法?

Naw*_*waz 6

oct并且hex是定义的流操纵器<ios>,而abc不是任何标准头中定义的符号.因此,您只能看到abc的错误,因为您没有在程序中自己声明它.

除此之外,您似乎使用的是非常旧的编译器<iostream.h>.我建议你更新你的编译器(或切换到更好的编译器),并使用<iostream><iostream.h>不是标准头.

  • 可能是没有参数的操纵器在`<ios>中`并且在`<iomanip>`中更"高级".之前没想过. (2认同)