I am trying to befriend a class in order for it to be able to reach a private constructor of it.
In some_file.h
class B;
namespace some_name {
class A {
public:
A() {}
private:
A (int x) {}
friend class ::B;
};
}
In other_file.h
#include "some_file"
namespace {
class B {
protected:
A* get_a(int x) { return new A(x); }
};
}
When compiling this code, I get - error: 'some_name::A::A(int)' is private.
I now, it is private, this is why I befriended B. What am I doing wrong here? Can't you befriend your constructor? Is there a namespace issue?
Thanks