mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Merge pull request #4492 from bharathcs/patch-1
[c++/en] Update C++ docs to improve clarity on namespace.
This commit is contained in:
commit
a2d576f863
@ -158,6 +158,10 @@ namespace Second {
|
|||||||
{
|
{
|
||||||
printf("This is Second::foo\n");
|
printf("This is Second::foo\n");
|
||||||
}
|
}
|
||||||
|
void bar()
|
||||||
|
{
|
||||||
|
printf("This is Second::bar\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void foo()
|
void foo()
|
||||||
@ -168,10 +172,12 @@ void foo()
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Includes all symbols from namespace Second into the current scope. Note
|
// Includes all symbols from namespace Second into the current scope. Note
|
||||||
// that simply foo() no longer works, since it is now ambiguous whether
|
// that while bar() works, simply using foo() no longer works, since it is
|
||||||
// we're calling the foo in namespace Second or the top level.
|
// now ambiguous whether we're calling the foo in namespace Second or the
|
||||||
|
// top level.
|
||||||
using namespace Second;
|
using namespace Second;
|
||||||
|
|
||||||
|
bar(); // prints "This is Second::bar"
|
||||||
Second::foo(); // prints "This is Second::foo"
|
Second::foo(); // prints "This is Second::foo"
|
||||||
First::Nested::foo(); // prints "This is First::Nested::foo"
|
First::Nested::foo(); // prints "This is First::Nested::foo"
|
||||||
::foo(); // prints "This is global foo"
|
::foo(); // prints "This is global foo"
|
||||||
|
Loading…
Reference in New Issue
Block a user