What is the difference!

Between the local and enclosing scope?

Or are they the exact same?

Thanks!
You're probably talking about the same thing.
Enclosing scope is not necessary is a local scope. For example the global namespace is an enclosing scope for all declarations.:)
The local scope is the block scope. But names can be defined in other scopes as for example namespace scopes, function prototype scopes or function scopes.
Last edited on
"For example the global namespace is an enclosing scope for all declarations.:)"

What do mean global namespace is an enclosing scope?
@Anmol444
What do mean global namespace is an enclosing scope?


This means that all declarations are enclosed in the global namespace. Any namespace is enclosed in the global name space. For example

namespace outer
{
namespace inner
{
}
}

Here the both namespaces are enclosed in the global namespace. Also namespace inner is inclosed in namespace outer.
Any function declaration are enclosed in some namespace.
Any local scope is enclosed in a block scope.
I am still very confused lol.
Consider all scopes as a tree with the root node that is the global scope.
But what is the difference between enclosing and local or are they the exact same?
You can say about enclosing scope relative to some declaration. There is no such entity as enclosing scope without some other enity that is enclosed.:)
As I showed above in this example

namespace outer
{
namespace inner
{
}
}

You can say that outer is enclosing scope only relative to scope inner. So any local scope is enclosing scope relative to all declarations that are done in this scope except declarations with external linkages. But the enclosing scope does not equivalent to the local scope as it is shown from the presented example with namespaces.
Topic archived. No new replies allowed.