OSDN Git Service

new testcases
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.pt / tiemann2.C
1 extern "C" void printf (char *, ...);
2 template <class T> T max (const T&x, const T&y)
3 {
4   return (x>y)?x:y;
5 }
6
7 class complex
8 {
9   double re, im;
10  public:
11   complex (double r, double i=0) { re = r; im = i; }
12   friend int operator > (const complex& x, const complex &y);
13   void print () { printf ("re = %g; im = %g;\n", re, im); }
14 };
15 int operator >(const complex& x, const complex &y)
16 {
17   double c1 = x.re * x.re + x.im * x.im;
18   double c2 = y.re * y.re + y.im * y.im;
19   return c1 > c2;
20 }
21
22 main ()
23 {
24   complex c1 (1, 0);
25   complex c2 (2, 0);
26   complex c3 (2, 3);
27   complex c4 (2, 1);
28
29   complex m1 = max (c1, c2);
30   complex m2 = max (c3, c4);
31   m1.print ();
32   m2.print ();
33   return 0;
34 }