Re: pure virtual method
<mfabricius@gmail.com> wrote in message...
Hi,
I am probably trying to do something really stupid.
There is a class shape:
class Shape{ public:
Shape();
virtual ~Shape();
...
virtual bool inside(prec_t x, prec_t y) = 0;
...
virtual Shape * copy() = 0;
...
};
You might want to 'define' those pure virtuals for testing.
bool Shape::inside( prec_t x, prec_t y){
std::cerr<<"base virtual \"Shape::inside()\" called"<<std::endl;
return false;
}
Shape* Shape::copy(){
std::cerr<<"base virtual \"Shape::copy()\" called"<<std::endl;
return this;
}
..... because of this:
class Surface{ public: ...
Shape* myShape; // <--------! slice if set to a derived?
}; // ADD the semicolon!!!
1) upperShell.shape = this->shape->copy();
There is no 'upperShell' in the incomplete code you showed.
There is no 'shape' in the incomplete code you showed.
( did you mean 'myShape'? )
You also failed to show the definitions for:
Circle::inside()
Circle::copy()
FAQ http://www.parashift.com/c++-faq-lite
--
Bob R
POVrookie