File: defining.yo

package info (click to toggle)
c%2B%2B-annotations 8.2.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 11,804 kB
  • ctags: 2,845
  • sloc: cpp: 15,418; makefile: 2,473; ansic: 165; perl: 90; sh: 29
file content (44 lines) | stat: -rw-r--r-- 1,401 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Namespaces are defined according to the following syntax:
        verb(
    namespace identifier
    {
        // declared or defined entities
        // (declarative region)
    }
        )
    The identifier used when defining a namespace is a standard bf(C++)
identifier.

    Within the emi(declarative region), introduced in the above code example,
functions, variables, structs, classes and even (nested) namespaces can be
defined or declared. Namespaces cannot be defined within a function
body. However, it is possible to define a namespace using multiple
em(namespace) declarations. Namespaces are `em(open)' meaning that
a namespace tt(CppAnnotations) could be defined in a file tt(file1.cc) and
also in a file tt(file2.cc). Entities defined in the tt(CppAnnotations)
namespace of files tt(file1.cc) and tt(file2.cc) are then united in one
tt(CppAnnotations) namespace region. For example:
        verb(
    // in file1.cc
    namespace CppAnnotations
    {
        double cos(double argInDegrees)
        {
            ...
        }
    }

    // in file2.cc
    namespace CppAnnotations
    {
        double sin(double argInDegrees)
        {
            ...
        }
    }
        )
    Both tt(sin) and tt(cos) are now defined in the same
tt(CppAnnotations) namespace.

    Namespace entities can be defined outside of their namespaces. This
topic is discussed in section ref(OUTSIDE).