n C++, namespace defines a _____ for the identifiers that are used in a program.
2021
n C++, namespace defines a _____ for the identifiers that are used in a program.
Answer: B. scope — In C++, a namespace is used to define a scope for identifiers such as variables, functions, and classes. It helps avoid naming conflicts when different parts…
- A.
size
- B.
scope
- C.
syntax
- D.
standard
Attempted by 61 students.
Show answer & explanation
Correct answer: B
In C++, a namespace is used to define a scope for identifiers such as variables, functions, and classes. It helps avoid naming conflicts when different parts of a program use the same identifier names.
Example:
namespace A {
int x;
}Here, A creates a separate scope for x.
Loading lesson…