Comment

Comment by PaulDavisThe1st

I'd like them extended slightly, in fact. I'd like a friend declaration after an access specifier to apply only until the next access specifier. Eg.

     class Foo {
       public:
          void method_A();
 
       protected:
          friend class Bar;
          void method_B();

       protected:
          friend class Baz;
          void method_C();

       private:
          void method_D();
     };
anyone can call method_A(), only Bar can call method_B(), only Baz can call method_C() and nobody can call method_D().

You can do this by inheriting from 2 different pure abstract classes, but that feels much kludgier to me.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton