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. scopeIn 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…

  1. A.

    size

  2. B.

    scope

  3. C.

    syntax

  4. 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.

Explore the full course: Dsssb Tgt Computer Science Paper 2

Loading lesson…