unnamed namespaces

Discussion in 'C++' started by Anthony, Feb 21, 2004.

  1. Anthony

    Anthony Guest

    Hello,

    I have been reading up on unnamed namespaces in the context of hiding
    classes as mentionned by the GOF Facade pattern description. I was
    hoping someone could shed some light on this.
    I would like the following classes where Facade has access to Alpha
    and Beta which are otherwise hidden.

    class Alpha
    {
    Beta b;
    // and methods which call b methods
    };

    class Beta
    {
    Alpha a;
    // and methods which use a methods
    };

    class Facade
    {
    // various manipulations of Alpha and Beta objects
    };

    However I would like to be able to seperate these classes into
    seperate files (as in the case of say a compiler with a facade, the
    subsystem classes are numerous and large and keeping this in one file
    would be crazy). Is this at all feasible with unnamed namespaces as
    the GOF book describes? My major problem is the organisation of the
    code in headers and source files. On this front I'm totally lost!

    NB: Yes I know I could always do this with private constructors and
    friend classes but I would like to see a namespace version in action.

    Any help would be greatly appreciated.

    Many Thanks

    Anthony
    Anthony, Feb 21, 2004
    #1
    1. Advertising

  2. Anthony

    John Carson Guest

    "Anthony" <> wrote in message
    news:
    > Hello,
    >
    > I have been reading up on unnamed namespaces in the context of hiding
    > classes as mentionned by the GOF Facade pattern description. I was
    > hoping someone could shed some light on this.
    > I would like the following classes where Facade has access to Alpha
    > and Beta which are otherwise hidden.
    >
    > class Alpha
    > {
    > Beta b;
    > // and methods which call b methods
    > };
    >
    > class Beta
    > {
    > Alpha a;
    > // and methods which use a methods
    > };
    >
    > class Facade
    > {
    > // various manipulations of Alpha and Beta objects
    > };
    >
    > However I would like to be able to seperate these classes into
    > seperate files (as in the case of say a compiler with a facade, the
    > subsystem classes are numerous and large and keeping this in one file
    > would be crazy). Is this at all feasible with unnamed namespaces as
    > the GOF book describes?



    No, it is not feasible. Stroustrup TC++PL, p 177: "In particular, unnamed
    namespaces in different translation units are different. As desired, there
    is no way of naming a member of an unnamed namespace from another
    translation unit."


    --
    John Carson
    1. To reply to email address, remove donald
    2. Don't reply to email address (post here instead)
    John Carson, Feb 21, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mattia Belletti

    unnamed object creation

    Mattia Belletti, Oct 20, 2003, in forum: Java
    Replies:
    4
    Views:
    428
    Jason Us
    Oct 22, 2003
  2. Mysooru

    Unnamed "Formal Parameter"

    Mysooru, Jul 24, 2003, in forum: C++
    Replies:
    3
    Views:
    452
    Mike Wahler
    Jul 24, 2003
  3. Razmig K
    Replies:
    3
    Views:
    683
    John L Fjellstad
    Sep 5, 2003
  4. Jordi Vilar
    Replies:
    5
    Views:
    2,281
    Jonathan Turkanis
    Feb 18, 2004
  5. marco_segurini
    Replies:
    4
    Views:
    1,003
    Rob Williscroft
    Jun 16, 2004
Loading...

Share This Page