CppPatterns-Patterns icon indicating copy to clipboard operation
CppPatterns-Patterns copied to clipboard

Suggestion: In the CRTP example, make impl method private in the derived class

Open panikgit opened this issue 2 years ago • 0 comments

Method do_something_impl is private in the base class and public in the derived class foo.

https://github.com/sftrabbit/CppPatterns-Patterns/blob/a222c8438d2c9e81114b9408c2e6a8e767bffb0b/common-tasks/classes/delegate-behavior-to-derived-classes.cpp#L21-L28

For consistency, make do_something_impl private.

class foo : public base<foo>
{
  friend class base<foo>;
  private:
    void do_something_impl()
    {
      // Derived implementation
    }
};

panikgit avatar Aug 15 '22 20:08 panikgit