2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.law / ctors12.C
blobadc5128ea7c538a15220ab82379888126de028a3
1 // { dg-do run  }
2 // GROUPS passed constructors
3 #include <cstdio>
4 #include <cstdlib>
5 #include <iostream>
7 #define MAGIC 7654
9 class complex {
10         double re;
11         double im;
12         int magic;
13         static int count;
14 public:
15         complex() { re=im=0; magic=MAGIC; }
16         complex(double d) { re=d; im=0; magic=MAGIC; }
17         complex(double d, double d2) {re=d; im=d2; magic=MAGIC; }
18         ~complex() {if(magic!=MAGIC) {std::printf("FAIL\n"); std::exit(1);}}
19         friend std::ostream& operator << (std::ostream& o, const complex& c)
20         { return o << "(" << c.re << "," << c.im << ")"; }
23 int complex::count=0;
25 int main()
27         complex v[6] = {1, complex(1,2), complex(), 2 }; // ARM Sect. 12.6.1
28         int i;                                           // page 289
30         for(i=0; i<6; i++) ;
31         std::printf ("PASS\n");
33         return 0;