No whitespace between a cast and a namespace operator?

Posted by Pod on Stack Overflow See other posts from Stack Overflow or by Pod
Published on 2010-04-08T12:34:33Z Indexed on 2010/04/08 12:53 UTC
Read the original article Hit count: 325

Filed under:
|

Hello. Could anyone please explain the following line of code, found on http://docs.openttd.org/ai__cargo_8cpp_source.html

return (AICargo::TownEffect)::CargoSpec::Get(cargo_type)->town_effect;

If this line was:

return (AICargo::TownEffect) ::CargoSpec::Get(cargo_type)->town_effect;

(note the space between TownEffect) and the ::) then I would understand it fine. However there is no whitespace in that document*, which would mean (AICargo::TownEffect) is the left operand of the :: operator.

How does this code work/compile? Or are the two things equivilent due to some obscure C++ rule?

*It's the same in the cpp file as well.

© Stack Overflow or respective owner

Related posts about c++

Related posts about namespaces