Understanding C++ Expression Templates - Angelika Langer
Understanding C++ Expression Templates - Angelika Langer
Understanding C++ Expression Templates - Angelika Langer
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
36Compile-Time PolymorphismReplace intrusive inheritance by name commonality:class Ellipse{public: Ellipse(intint x, int y): Xradius(x),Yradius(y) { }void rotate(intint);private:int Xradius,YradiusYradius;};class Rectangle {public: Rectangle(intx, int y): Xedge(x),Yedge(y) { }void rotate(intint);private:int Xedge, Yedge;};© Copyright 1995-2000 by <strong>Angelika</strong> <strong>Langer</strong>. All Rights Reserved.http://www.<strong>Angelika</strong><strong>Langer</strong>.com(71)last update: 11/7/2005 ,21:37Compile-Time PolymorphismUsing compile-time polymorphism:template void vertical_flip(Rotatable& d){ d.rotate(180); }Ellipse ellipse(100,600);vertical_flip(ellipse);Rectangle rectangle(999,500);vertical_flip(rectangle);© Copyright 1995-2000 by <strong>Angelika</strong> <strong>Langer</strong>. All Rights Reserved.http://www.<strong>Angelika</strong><strong>Langer</strong>.com(72)last update: 11/7/2005 ,21:37