Cumulative

Steve Teale steve.teale at britseyeview.com
Fri Mar 7 02:31:23 PST 2014


On Friday, 7 March 2014 at 10:05:56 UTC, John Colvin wrote:
> On Friday, 7 March 2014 at 09:43:07 UTC, Steve Teale wrote:
>> On Friday, 7 March 2014 at 09:04:29 UTC, John Colvin wrote:
>>> How would these plain functions be different from final ones?
>>
>> You would be able to redefine them in a derived class using 
>> override to tell the compiler that it was intentional.
>
> So the compiler would choose which function is called based on 
> the compile-time type of the class reference, instead of the 
> runtime type info? Inheritance without the polymorphism.

Twould be as in this C++, is that what you mean?

#include <iostream>

class A
{
public:
    void foo() { std::cout << "This is A\n"; }
};

class B: A
{
public:
    void foo() { std::cout << "This is B\n"; }
};

int main()
{
    A* a = new A();
    B* b = new B();
    a->foo();
    b->foo();
}

My, it was painful writing that!


More information about the Digitalmars-d mailing list