IF you know the pure virtual function has a definition then the only way you're going to call it is to do so explicitly. In the example you gave you can use an object of class B:
int main()
{
B b;
b.A::f();
}
Of course if the library hasn't implemented the pure virtual function then you'll get some sort of warning like "Pure virtual function called" and your code will crash in a heap.
If there aren't any derived classes of A that you can explicitly call through you'll have to derive your own class and override the virtual function:
class C : public A
{
public:
virtual void f()
{
A::f();
}
};
int main()
{
C c;
c.f();
}
Again, if A::f() hasn't an implementation then your code is on the way to crash city.
Normally when you declare a function as pure virtual you're not going to implement it as pure virtual functions specify an interface. Having said that there are two main reasons why you'd implement a pure virtual function:
- destructors need a body, even if pure virtual
- to provide default behaviour for a virtual function but make the deriver explicitly say they want the default behaviour.
Cheers,
Ash