473,614 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unnamed namespaces

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
Jul 22 '05 #1
1 1664
"Anthony" <to**@transcend enz.co.uk> wrote in message
news:23******** *************** ***@posting.goo gle.com
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)

Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2157
by: Marco Jez | last post by:
What are the requirements imposed by the Standard on unnamed namespaces? I mean, is the hidden name guaranteed to be unique across multiple translation units, or only within the declaring translation unit? My question comes from a problem I'm seeing with code compiled with MSVC++. I have multiple files which declare types and variables whose name is the same across units, but they're declared inside unnamed namespace and so their...
3
2342
by: Sandy | last post by:
Hi, I have two files as folllows file1.cpp #include<iostream> using namespace std; namespace { void show(); void fun() { cout<<"fun called\n"; } }
2
9516
by: Frank Roland | last post by:
I know it is possible to use unnamed struct or unions inside of struct like in the following example: typedef struct { union { int moin; char carl; }; int bon; } dastruct;
2
1269
by: dioscuroi | last post by:
Is there any difference between declaring in unnamed namespace and i global namespace? I can't recognize this p.s: Have a nice day ^_________ -
9
5453
by: Ivan Mascovich | last post by:
Previous posts (and compilers) confirm that class X { friend void Y() ; } ; does not match namespace
3
2597
by: Tomás | last post by:
I have a header file/source file combo. There's approximately five functions in the source file. Only one of the functions should be used by other translation units, so I've defined the other four functions within an unnamed namespace. The header file only contains a declaration for the one function. My function needs to call the other four functions. My code won't compile, giving the following error:
9
2302
by: Tom Plunket | last post by:
The project I'm currently on makes heavy use of unnamed structures to represent an "object hierarchy" of a sort. E.g. struct BaseObject { int aMember; int anotherMember; // etc.
1
2009
by: vsgdp | last post by:
I just want to clarify: Say I have a helper class that is only used in one translation file (e.g., a predicate class). I don't want the name of this class to conflict with other class names in other files, so I put it in a nameless namespace?
3
2272
by: CrazyJohn | last post by:
Hi guys, This is my first time posting question here, if I break any rules, please kindly point out. And I'm really glad to be a part of this community. Here is my question, Our lecturer told us that Unnamed Namespace is an alternative to Static Internal Variables, but he also said that Namespace has an
0
8124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8621
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8272
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8427
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4049
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4119
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1712
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.