I have the following scheme:
class Interface
{
virtual ~Interface() { }
virtual void foo() const = 0;
virtual void bar() const = 0;
}
//Interface is derived privately mostly for preventing upcast outside
class Derived : private Interface
{
public:
void foo() const;
private:
void bar() const;
}
It does not compile : foo
is private. Is there any way to make it public without adding a dummy public function?
No, there is not.
Furthermore, even a dummy public function would require that
foo
in the base wereprotected
, notprivate
.I would revisit your design. If the function is intended to be public, then why is it not
public
?