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!

Reply via email to