Partial implementation in derived classes
I tried to build program with partial implementation.
However a linker generates errors.
Is there any approach that enables to use partial implementation for similar purposes?
------ foo.cpp ---
struct Base
{
virtual void foo1() = 0;
virtual void foo2() = 0;
};
struct Derived1 : public Base
{
void foo1() {}
void foo2(); // Not for use
};
struct Derived2 : public Base
{
void foo1(); // Not for use
void foo2() {}
};
int main ()
{
Base* p1 = new Derived1();
Base* p2 = new Derived2();
// -----------------------
// I would like to get linkage error in the following cases:
// p1->foo2();
// p2->foo1();
// -----------------------
return 0;
}
------ foo.cpp ---
------ Compilation ------
// gpp: GNU C++ 4.0.1 (DJGPP)
$ gpp foo.cpp
c:/djgpp/tmp/cccl1W22.o:foo.cpp:(.gnu.linkonce.t._ZN8Derived1C1Ev+0x16): undefined reference to `vtable for Derived1'
c:/djgpp/tmp/cccl1W22.o:foo.cpp:(.gnu.linkonce.t._ZN8Derived2C1Ev+0x16): undefined reference to `vtable for Derived2'
collect2: ld returned 1 exit status
-------------------------
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn