There is not much you can do other then to separate the construction of the A::B
from its initialization to avoid this chicken-and-egg-problem:
class A::B{
int x;
void init(A &a, int value){
a.setX(value);
}
friend class A;
};
A::A(int val) : bp(new B){
bp->init(*this, val);
}