PageRenderTime 31ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/modula3/class/example.h

#
C++ Header | 44 lines | 40 code | 3 blank | 1 comment | 0 complexity | d0c3da92d5e5168b5e1f2b3cc06e95ae MD5 | raw file
 1/* File : example.h */
 2
 3class Shape
 4{
 5public:
 6  Shape ()
 7  {
 8    nshapes++;
 9  }
10  virtual ~ Shape ()
11  {
12    nshapes--;
13  };
14  double x, y;
15  void move (double dx, double dy);
16  virtual double area (void) const = 0;
17  virtual double perimeter (void) const = 0;
18protected:
19  static int nshapes;
20};
21
22class Circle:public Shape
23{
24private:
25  double radius;
26public:
27    Circle (double r):radius (r)
28  {
29  };
30  virtual double area (void) const;
31  virtual double perimeter (void) const;
32};
33
34class Square:public Shape
35{
36private:
37  double width;
38public:
39    Square (double w):width (w)
40  {
41  };
42  virtual double area (void) const;
43  virtual double perimeter (void) const;
44};