PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/php/overloading/example.h

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