PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/java/class/example.h

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