I don't know exactly what you mean...
Do you mean that only the constructor can be invoked by a friend from any of its methods;
or do you mean that only a certain function in a friend can invoke the constructor?
The first thing does NOT exist, a friend Method/class allways sees everything inside the class.
The second thing works partialy, but this method can see everything in the class (which makes sense)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class A
{
public:
A();
};
class F
{
F() {}
int i; // also visible from A::A()
public:
friend A::A();
};
A::A() {
F f;
f.i = 20;
}
A constructor is a (special) function so you can declare a constructor as friend just like you can with normal functions. The same could be said about operators.