M
mc
Hello,
I'm trying to create a class (A) with a default constructor friend to
another one (B) as follows:
class A
{
public:
A(int a);
~A();
private:
A(); // default constructor
}
class B
{
// must be able to use A::A()
}
What I need is that only A and B can use the private default constructor
(A::A()). By adding a "friend class B;" in class A, I got it to work but I
do not want B to be able to access the whole of A. Is there a way to do
this? Thank you in advance.
Regards,
MC
I'm trying to create a class (A) with a default constructor friend to
another one (B) as follows:
class A
{
public:
A(int a);
~A();
private:
A(); // default constructor
}
class B
{
// must be able to use A::A()
}
What I need is that only A and B can use the private default constructor
(A::A()). By adding a "friend class B;" in class A, I got it to work but I
do not want B to be able to access the whole of A. Is there a way to do
this? Thank you in advance.
Regards,
MC