Bug 7242 – Cannot call base class member function with same name but diff parameters
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2012-01-07T03:37:00Z
Last change time
2012-01-07T22:45:58Z
Assigned to
nobody
Creator
full.demon
Comments
Comment #0 by full.demon — 2012-01-07T03:37:35Z
class A
{
public:
void f(int i)
{
}
}
class B: A
{
public:
void f()
{
}
}
int main()
{
B b = new B;
b.f(1);
}
Error: function main.B.f () is not callable using argument types (int)
Error: expected 0 arguments, not 1 for non-variadic function type void()
Comment #1 by bugzilla — 2012-01-07T22:45:58Z
This is by design. Overloads are done against functions in the current scope, not across all accessible scopes.
You can pull the base class functions into the current scope by adding this line:
alias A.f f;
to B.