Syntax

C++ Namespace Syntax

In C++, namespace: groups names to avoid clashes — namespace app { int version = 1; }

Quick Answer

Syntax
namespace app { int version = 1; }
C++Syntax

Namespace

Code example
namespace app { int version = 1; }

Groups names to avoid clashes.

Learn More

How to namespace in C++

  1. Open your C++ file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C++ Namespace Syntax

Use namespace app { int version = 1; }.

Related Syntax References

Frequently asked questions

What is the C++ syntax for namespace?

Use this pattern: namespace app { int version = 1; }

Can I copy this C++ code example?

Yes. Use Copy code and adapt the example to your program.

Is this C++ syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify