summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarcel Ribeiro Dantas <ribeirodantasdm@gmail.com>2022-08-29 09:53:15 -0300
committerGitHub <noreply@github.com>2022-08-29 09:53:15 -0300
commita2d576f8638fe8f14a328645ea1f8bce7d608121 (patch)
tree6b454f2798013c40b026e5b57b17e6e3dd731d79
parente6f2e1420c9f76c0282cf50ffe01f2026cb2d92b (diff)
parent5faaf058e1fa5f4d1da6d00948f94c88b058d68d (diff)
Merge pull request #4492 from bharathcs/patch-1
[c++/en] Update C++ docs to improve clarity on namespace.
-rw-r--r--c++.html.markdown10
1 files changed, 8 insertions, 2 deletions
diff --git a/c++.html.markdown b/c++.html.markdown
index 33ef70f3..499eb669 100644
--- a/c++.html.markdown
+++ b/c++.html.markdown
@@ -158,6 +158,10 @@ namespace Second {
{
printf("This is Second::foo\n");
}
+ void bar()
+ {
+ printf("This is Second::bar\n");
+ }
}
void foo()
@@ -168,10 +172,12 @@ void foo()
int main()
{
// Includes all symbols from namespace Second into the current scope. Note
- // that simply foo() no longer works, since it is now ambiguous whether
- // we're calling the foo in namespace Second or the top level.
+ // that while bar() works, simply using foo() no longer works, since it is
+ // now ambiguous whether we're calling the foo in namespace Second or the
+ // top level.
using namespace Second;
+ bar(); // prints "This is Second::bar"
Second::foo(); // prints "This is Second::foo"
First::Nested::foo(); // prints "This is First::Nested::foo"
::foo(); // prints "This is global foo"