[haiku-development] Re: inline BListView::ScrollTo()

Ingo Weinhold wrote:
On 2008-02-24 at 11:05:34 [+0100], Stephan Assmus <superstippi@xxxxxx> wrote:
there is a BListView::ScrollTo(float x, float y) implemented inline in the
ListView header. BView already has the exact same method. Both call through
to ScrollTo(BPoint) (which is virtual). Can the BListView version be
removed without breaking anything?

C++ has a pretty annoying shadowing behavior in this case. Overriding only one of several overloaded methods will hide all others. I.e. you won't be able to invoke ScrollTo(float, float) on a BListView (or derived class) typed variable anymore. Explicitly invoking BView::ScrollTo(float, float) would work, but it's probably more convenient to just override this method as well.

I discussed this in my lab yesterday, and one of the guys went and looked at the spec - there is a cleaner solution:

class BListView : public BView
{
public:
  using BView::ScrollTo(float, float);
...
}

It's like that so that name lookup and overload resolution can happen in two distinct steps.

Simon

Other related posts: