Rani wrote:
Tomás wrote:
Here's the sample code file which demonstrates the problem:
Put this new declaration here -
namespace { void Ape(); } void Monkey()
{
Comment out the follg declaration void Ape(); //Function Declaration
Ape();
}
namespace {
void Ape()
{
;
}
}
Well doesn't that sort of nullify the whole reason for unnamed
namespaces? What if you really want to make that type only visible to
your class or function and those that use it no?
I had a similar problem and I had to not use the namespace to solve it,
but I would have liked finding another way:
X.h...
class X
{
friend class Y;
public:
Z * getZ() const;
};
X.cpp....
#include "Z.h"
#include "X.h"
namespace
{
class Y : public Z { ... };
};
Z * X::getZ() { return new Y(); }
If Y is in an anonymous namespace that code won't work, but if it isn't
then it does. Not that big of a deal but it makes me wonder how you
address things like this.
If you declared a namespace { class Y; } before the class definition of
X then now everyone that includes X.h knows about Y, no?