I was going through: C++ FAQs about inheritance and decided to implement it (just to learn it)
#include "Shape.h"
void Shape::print() const
{
float a = this->area(); // area() is pure virtual
...
}
now, everything (well, almost) works as described in item: faq:23.1 except that print() is const and so it can't access the "this" pointer, as soon as you take out const, it works. Now, C++ FAQs have been around for a while and are usually pretty good. Is this a mistake? Do they have typo or am I wrong? If I'm wrong, I would like to know how is it possible to access the "this" pointer in a const function.