Re: Implementation of abstract classes
On Sep 21, 4:55 pm, Rune Allnor <all...@tele.ntnu.no> wrote:
On 20 Sep, 19:12, Erik Wikstr=F6m <Erik-wikst...@telia.com> wrote:
Just because a function is pure virtual does not mean it
cannot be implemented:
#include <iostream>
struct Base
{
virtual ~Base() = 0
{
std::cout << "~Base\n";
}
};
Can this be correct? The way I understand
virtual void foo() = 0;
is that the statement inituializes a NULL pointer in the
virtaul function table.
It might. All the standard says is that if a virtual function
call resolves to a pure virtual function, the behavior is
undefined.
It this is correct your code above will result in undefined
behaviour.
Only if you manage to have a virtual function call resolve to
Base::~Base. And I don't see any way of doing that that
wouldn't create undefined behavior anyway. (Basically, the only
way you could have it would be with an explicit destructor call
from a constructor or the destructor of Base.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34