#include <iostream> namespace { int a=1; } int a=2,b=3; int main(void) { std::cout<<::a<<::b; return 0; }
I agree with my g ++, but conclusion 23, who can explain this? is this a way to access <unnamed> namespace ::a?
<unnamed> namespace ::a
::in ::arefers to the global namespace. An anonymous namespace should be accessible through only a(or, to be more specific, you should not do this at all)
::
::a
a
No, you can’t. You can get around it this way:
namespace { namespace xxx { int a = 1; } } ... std::cout << xxx::a << ::b;
, . .
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/unnamed_namespaces.htm
.
You can access the global namespace, but do not redefine it.
#include <iostream> namespace { int a=1; } int b=3; int main(void) { std::cout<<::a<<::b; return 0; }
here the output is 13.
Source: https://habr.com/ru/post/1740896/More articles:Polymorphic functions with parameters from the class hierarchy - c ++Насколько плохо для SEO "перенаправить" пользователя в зависимости от его локали браузера? - seoС# Анонимная проблема с переменной переменной метода с IEnumerable - scopeApplication development with access to cameras and GPS - cameraSQL: where vs. on in connection - sqlHow to determine text spacing in css input - csshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1740898/what-happens-to-a-transaction-when-app-pool-recycles-or-the-worker-process-is-terminated-forcefully&usg=ALkJrhh2DdtnvOVYPS1Dn-sQO9vmQIgCmAUnable to submit list to a web service? - c #Does version control content management system? - gitКак я могу сделать ссылку для обновления своего iPhone-приложения? - urlAll Articles