H
Hicham Mouline
Hello,
A semi-skeptical colleague is asking me why friendship is not inheritable,
specifically:
class Base {
public:
virtual void f() const =0;
};
class Derived : public Base {
virtual void f() const { // impl };
};
class A {
friend void Base::f() const;
};
In the implementation of Derived::f() const,
it cannot access private members of A.
you have to actually make Derived::f() friend of A.
Is this part of the standard? Or is it unspecified?
Is the rationale explained somewhere?
PS: I tested this only with VS2005
regards,
A semi-skeptical colleague is asking me why friendship is not inheritable,
specifically:
class Base {
public:
virtual void f() const =0;
};
class Derived : public Base {
virtual void f() const { // impl };
};
class A {
friend void Base::f() const;
};
In the implementation of Derived::f() const,
it cannot access private members of A.
you have to actually make Derived::f() friend of A.
Is this part of the standard? Or is it unspecified?
Is the rationale explained somewhere?
PS: I tested this only with VS2005
regards,