mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Fix C++ namespace explanation
This commit is contained in:
parent
55735f8b6c
commit
97b97408ea
@ -158,11 +158,12 @@ void foo()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Assume everything is from the namespace "Second"
|
// Includes all symbols from `namesapce Second` into the current scope. Note
|
||||||
// unless otherwise specified.
|
// that simply `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;
|
using namespace 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