Hello!
While experimenting with C++ language, I came across intersting
behavior.
Suppose class Derived privately inherits from class Base.
Derived cannot be implicitly converted to Base because it is
inherited privately (Derived IS-NOT-A Base).
Now I add two overloaded functions, one which takes a pointer to
Base and the other which just takes ellipsis.
Example:
class Base { };
class Derived : private Base { };
void test(Base *ptr);
void test(...);
//...
Now if I call the function test() and pass a pointer to a Derived
class,
function test(Base *ptr) get's selected as if Derived could be
converted to
Base and then compiler errors that Derived cannot be converted to
Base.
Example:
test(new Derived);
Why doesn't the compiler select test(...) as the best match?
P.Krumins