diff options
Diffstat (limited to 'doc/sources/c++/triangle.cpp')
-rw-r--r-- | doc/sources/c++/triangle.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/sources/c++/triangle.cpp b/doc/sources/c++/triangle.cpp new file mode 100644 index 0000000..96185d0 --- /dev/null +++ b/doc/sources/c++/triangle.cpp @@ -0,0 +1,22 @@ +#include "polygon.hpp" +#include <cmath> + +class triangle : public polygon +{ + public: + virtual double area() const + { + return side_length_ * side_length_ * sqrt(3) / 2; + } +}; + +// the class factories +extern "C" polygon* create() +{ + return new triangle; +} + +extern "C" void destroy(polygon* p) +{ + delete p; +} |