G
Guest
Hi, I am running into a problem with members which have the same name
in several base classes but different calling types and the comipler
complaining about amiguosity.
The VC++ docu list the following example:
struct A
{
void x(int i)
{
printf("\nIn A::x");
}
};
struct B
{
void x(char c)
{
printf("\nIn B::x");
}
};
struct C : A, B
{
// uncomment the following two lines to resolve this C2385
// using B::x;
// using A::x;
};
int main()
{
C aC;
aC.x(100); // C2385
aC.x('c'); // C2385
}
This also happens with types which have no valid conversions. Why that?
The compiler knows which type I am using, so why can't it choose the
correct member as it does if the two members of the same name are in
one class?
Second: The solution with the using directive given in the help does
not work if each base has several member of the same name like:
struct A
{
void x(type1);
void x(type2)
};
struct B
{
void x(type3)
void x(type4)
};
Any solution to that except using different names?
Thanks in advance for any comments.
Timm
in several base classes but different calling types and the comipler
complaining about amiguosity.
The VC++ docu list the following example:
struct A
{
void x(int i)
{
printf("\nIn A::x");
}
};
struct B
{
void x(char c)
{
printf("\nIn B::x");
}
};
struct C : A, B
{
// uncomment the following two lines to resolve this C2385
// using B::x;
// using A::x;
};
int main()
{
C aC;
aC.x(100); // C2385
aC.x('c'); // C2385
}
This also happens with types which have no valid conversions. Why that?
The compiler knows which type I am using, so why can't it choose the
correct member as it does if the two members of the same name are in
one class?
Second: The solution with the using directive given in the help does
not work if each base has several member of the same name like:
struct A
{
void x(type1);
void x(type2)
};
struct B
{
void x(type3)
void x(type4)
};
Any solution to that except using different names?
Thanks in advance for any comments.
Timm