Visual C++ .NET: A primer for C++ developers error
On page 51, when discussing abstract classes, it says that writing default implementations for all methods in abstract classes is not possible using C++'s pure virtual syntax.
That's not true.
Try the following C++:
--------8<--------
#include <iostream>
struct base {
virtual void f() = 0;
};
void base::f()
{
std::cout << "base::f() called\n";
}
struct derived : public base {
void f();
};
void derived::f()
{
std::cout << "derived::f() called\n";
base::f();
}
int main()
{
derived d;
d.f();
}
--------8<--------
You can define default implementations for PVFs.
|