"Tobias Erbsland" <ne***************@tracker.drzoom.chwrote in message
news:45**********************@news.sunrise.ch...
: I'm not really sure if this should be possible according to the
: standard, because didn't found anything in the FAQ and in the C++ book
: about that.
:
: ==== example ===
: class A
: {
: public:
: virtual void foo( int x = 0 ) = 0;
: };
:
: class B : public A
: {
: public:
: virtual void foo( double x = 0.0 ) = 0;
: };
:
: class Impl : public B
: {
: public:
: virtual void foo( int x ) {};
: virtual void foo( double x ) {};
: };
:
: int main( int argc, char* argv[] )
: {
: B* b = new Impl();
: int x;
: b->foo();
: }
: ==== example ===
:
: I have two interfaces with pure virtual methods. But the methods of
the
: different interfaces are related together, because the B interface
: overloading the method from the interface A. And with the default
: arguments, it should be a conflict.
I am afraid that this would (unfortunately) be legal,
and will call B::foo(double 0).
Seen from an instance of Impl, A's methods are in a scope that
is "further out" than B's methods.
In other words, "A::foo(int)" is hidden by "B::foo(double)".
I have no further details to give. The thing is, it is a Bad Idea(TM)
to mix virtual functions with overloading *or* default parameters
( and that, you will find confirmed in books and FAQs ;) ), because
it can lead to unexpected changes of the meaning of your code.
There is no reason to get into this minefield.
Regards,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form