Follow Us
Contribute
  • Register
Errorbase is a collaborative writing project, that aims to build the largest trouble-shooting guide about all kinds of error messages.

Categories

0 votes

The member can derive from more than one object (it is inherited from more than one object). Ex:


// C2385 expected
#include <stdio.h>

struct A
{
    void x(int i)
    {
        printf_s("\nIn A::x");
    }
};

struct B
{
    void x(char c)
    {
        printf_s("\nIn B::x");
    }
};

struct C : A, B {}

int main()
{
    C aC;
    aC.x(100);
    aC.x('c');
}

struct C : A, B
{
    using B::x;
    using A::x;
};

requested by (170k points)

2 Solutions

0 votes

This article is a derivative work based on http://msdn.microsoft.com/en-us/library/42a01w2f.aspx" title="http://msdn.microsoft.com/en-us/library/42a01w2f.aspx" target="_blank">Compiler Error C2385 which is provided by http://msdn.microsoft.com/en-us/library/60k1461a.aspx" title="http://msdn.microsoft.com/en-us/library/60k1461a.aspx" target="_blank">MSDN Community Content - Visual C++.

solved by (170k points)
0 votes

To resolve this error,


  1. Make the member unambiguous by providing a cast.

  2. Rename the ambiguous members in the base classes.



// C2385 expected
#include <stdio.h>

struct A
{
    void x(int i)
    {
        printf_s("\nIn A::x");
    }
};

struct B
{
    void x(char c)
    {
        printf_s("\nIn B::x");
    }
};

struct C : A, B
{
    using B::x;
    using A::x;
};

int main()
{
    C aC;
    aC.x(100);
    aC.x('c');
}

struct C : A, B
{
    using B::x;
    using A::x;
};
solved by (170k points)
...