Xenos wrote in news:9D*******************@twister.nyroc.rr.com in
comp.lang.c++:
I just spend about an hour tracking down a link error with GCC. I had
defined a virtual member function, but never referenced it. With this
declaration, the linker would complain that the virtual table for the
class was missing. I know that it is acceptable by the standard to
declare a non-virtual member but not define it, if it is never
accessed. Is the same true for virtual members?
No, but you can declare the member pure-virtual, in which case
(as long as it isn't the destructor) you don't need a defenition.
However it makes the class *abstract*, i.e. you may not create
instances of it (even if you do provide a defenition).
struct X
{
virtual int f() = 0; /* = 0 means: pure */
};
struct Y : X
{
virtual int f();
};
int Y::f()
{
return 0;
}
int main()
{
Y y;
return y.f();
}
Rob.
--
http://www.victim-prime.dsl.pipex.com/