Re: Polymorphism without virtual in C++
On Aug 9, 4:46 am, feel <feel...@gmail.com> wrote:
On 8=E6=9C=888=E6=97=A5, =E4=B8=8B=E5=8D=884=E6=97=B617=E5=88=86, James K=
anze <james.ka...@gmail.com> wrote:
Thank you for your reply. I think you are right. I do not use
virtual functions as interface because the size of object.
Saying line, we can put two points as data implementation. But
if put many virtual functinos into class, we have to get a
bigger object than that object should be:
Only the first virtual function adds to the size of the object;
once the object has at least one virtual function, additional
virtual functions are free (at least in all of the
implementations I've every seen or heard of). Increased size is
not a reason to avoid virtual functions.
only two points!Object's size is very important in geometry
class design.
Pimpl can make sure the object's size is suitable for this
requirements.
The compilation firewall idiom actually increases memory use.
Either there's something I don't understand here, or you've
misunderstood something.
Polymorphism means in this case is like this: we can call
curve's getLength() function to get curve's length. but for
different kind of curves, we have to implementation different
method to compute it.
Exactly.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=C3=A9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=C3=A9mard, 78210 St.-Cyr-l'=C3=89cole, France, +33 (0)1 30 23 00 =
34