PageRenderTime 56ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/modula3/class/example.cxx

#
C++ | 28 lines | 19 code | 7 blank | 2 comment | 0 complexity | fd4e0fb0eb772486d019293f797d00c9 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* File : example.c */
  2. #include "example.h"
  3. #define M_PI 3.14159265358979323846
  4. /* Move the shape to a new location */
  5. void Shape::move(double dx, double dy) {
  6. x += dx;
  7. y += dy;
  8. }
  9. int Shape::nshapes = 0;
  10. double Circle::area(void) {
  11. return M_PI*radius*radius;
  12. }
  13. double Circle::perimeter(void) {
  14. return 2*M_PI*radius;
  15. }
  16. double Square::area(void) {
  17. return width*width;
  18. }
  19. double Square::perimeter(void) {
  20. return 4*width;
  21. }