www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7242] New: Cannot call base class member function with same name but diff parameters

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7242

           Summary: Cannot call base class member function with same name
                    but diff parameters
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: full.demon gmail.com



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()

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7242


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |INVALID



22:45:58 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 07 2012