Old problem with performance

Weed resume755 at mail.ru
Mon Feb 9 05:18:56 PST 2009


Kagamin пишет:
> Weed Wrote:
> 
>>>>> Well, D class code here is not equivalent to C++ class code. D code has more features, namely, it's polymorphic: C.opAdd is able to work with classes, derived from C, while corresponding C++ code is unable to do so.
>>  But I do not understand in what here problem. In C++ is impossible to
>> do overloading with "virtual" keyword?
>> Probably I badly know C ++, sorry.
> 
> In C++ you can't pass object derived from C to opAdd method. In D you can.

I am do not agree with you:

// C++:
class C {
    public:
        virtual void doSomething( C src ) {}
};

class C2 : public C {
};

int main( int argc, char* argv[] ) {
    C c;
    C2 c2;

    c.doSomething( c2 );

    return 0;
}



More information about the Digitalmars-d mailing list