English 中文(简体)
c++中,“主食”一词和 he子被定义为宏观吗?
原标题:Are the word oct and hex defined as macro in c++?
  • 时间:2012-04-29 06:34:34
  •  标签:
  • 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();   
    } 

<代码>oct和hex被定义为我列入的任何档案中的一些宏观因素,这就是为什么我没有在第二个<代码>cout上出现错误的原因?

最佳回答

stream ot/a>下定义的<ios>,而abc不是标准负责人界定的符号。 因此,你只看到abc的错误,因为你没有在你的节目中宣布这一错误。

除此以外,似乎你还重新使用由<条码>和代号;iostream.h>组成的老编。 我建议您更新编辑(或转向更精编的编辑),并使用<代码><iostream>而不是<iostream.h>,不是标准标题。

问题回答

你在这里犯了一个大错误。 你们不应试图通过阅读源码和实验学习C++。 这条道路将给你带来任何影响。

学习C++的唯一途径是获得。 优书,并读作涵盖面。

C++ is illogical in many places and no matter how smart you are there is no way you will guess correctly all of C++. Actually being too smart can be a problem for guessing because there are cases in which the C++ language design contains true mistakes that cannot be removed for backward compatibility reasons. If you are smart your guesses will be logical... and dead wrong.

还指出,虽然你常常可以写出几条清晰而合理的C++线,而且这些线将有效发挥作用,但也很有可能写出另外几条线,这些线更合乎逻辑,更看好,但会产生可怕的业绩和(或)不明确的行为。

不明确的行为还意味着,如果你在很多情况下犯错误,编辑和开学时间不会抱怨,事情一开始就会发生。 没有明确的行为是试验不是学习C++的良好途径的原因。

hex and oct are manipulators that are included in the std namespace. Their full names are actually std::hex and std::oct. There is no manipulator named abc, so that is why you get the error.

http://www.cplus.com





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签