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

/trunk/Examples/php/class/example.h

#
C++ Header | 38 lines | 34 code | 3 blank | 1 comment | 0 complexity | c2c1309fb85b53e993b072d976031a4c 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  static  int get_nshapes();
17};
18
19class Circle : public Shape {
20private:
21  double radius;
22public:
23  Circle(double r) : radius(r) { }
24  ~Circle() { }
25  void set_radius( double r );
26  virtual double area(void);
27  virtual double perimeter(void);
28};
29
30class Square : public Shape {
31private:
32  double width;
33public:
34  Square(double w) : width(w) { }
35  ~Square() { }
36  virtual double area(void);
37  virtual double perimeter(void);
38};