CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Termination of namespaces with a closing brace only ...

  1. #1
    Join Date
    Aug 1999
    Location
    Darmstadt, FRG
    Posts
    87

    Termination of namespaces with a closing brace only ...

    ... and not with a brace followed by a semicolon like in class-definitions - does anyone know the reason for that?

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Termination of namespaces with a closing brace only ...

    That's just what the rule is, I've never thought too hard about it.

    I suppose one *could* argue that a namespace is merely a scope, and like all scopes it doesn't require a closing semicolon, while a class definition is something a little different.

    You really have to punt to C, though----C required structs to be followed by a semicolon, so C++ kept the same pattern with classes. That's really all there is to it.

  3. #3
    Join Date
    Jul 2013
    Posts
    576

    Re: Termination of namespaces with a closing brace only ...

    Quote Originally Posted by greve View Post
    the reason
    Maybe it is because you can declare a variable of the class right away like,

    class A {
    } a;

    Most often you don't so almost always this is what you see,

    class A {
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)