c++ - Does not name a type error is due to existing enum, but why? -
I'm just getting this error: "Error: 'symbol is not a type of name"
< P> I got some other stack overflow questions that talked about circular dependence, but this is not the case here. In fact, I can reproduce it by putting it at the top of the source file: class symbol {int dummy;}; // class symbol {int then;}; Icon Global_Simbol;
It returns "error: 'symbol' not a type of name for type 3 'If I repeat the second line, then I still get this error, but before that That's what I found now: "Error: redefining 'class symbol' !! !!
After a lot of poking around it, it is a enum
in a third party library where the symbol
is defined. Neither the library uses my own code, the namespace, so if my code was taken inside the namespace, it was already on my to-do list. I do the next work and hopefully the problem is far Will run.
class symbol {}? If it fights with an enum, then I will not be able to instantify that class, why did not I complain? I think I am either missing a flag for either G ++
, or there is a difference in my C ++ knowledge, I say to tell myself that this is not a feature, it The bug is not there. (BTW I g ++ -c -std = gnu ++ 0x -Wall -g -Werror ..
and G ++ 4.8.1)
< / Div>
Hide name that you are looking for: a variable or function symbol announcement will be found in the class symbol
([basic.scope.hiding] §3.3 preference. 10/2). In those cases where C + + allows an announcement to hide one in the same scope, there is always a wide-type-specifier which still shows the hidden declaration. These are named because only one type ( class
or enum
) can be hidden like this; Typing and templates can not be done. The order of the announcement is not important.
In this situation, when you are in the variable or function scope, you can use the square symbol
:
class symbol global_symbol ;
Comments
Post a Comment