Hello everyone,
I've found out that the friend keyword can be used with a class or a function/method but I'm wondering if it's possible to do something like this :
class A;
class B;
class A {
private:
friend class B void AddEl(void *el);
friend class B void RemEl(void *el);
B *myB;
}
class B {
inline void Do() {
myA->RemEl(el2);
myA->AddEl(el1);
}
private:
A *myA;
}
In my code there is only one method of B (Do here) which needs the two private methods of A (AddEl and RemEl here). I can't use friend <method> because my class A is only forward-declared at this point (could be easily solved in the example above but not in my code). I can use friend class <class> but I think it's against the OOP and not safe.
Is there any way to declare friend of a class to methods like above ? Many thanks in advance.