1// GROUPS passed constructors 2#include <cstdio> 3#include <cstdlib> 4#include <iostream> 5 6#define MAGIC 7654 7 8class complex { 9 double re; 10 double im; 11 int magic; 12 static int count; 13public: 14 complex() { re=im=0; magic=MAGIC; } 15 complex(double d) { re=d; im=0; magic=MAGIC; } 16 complex(double d, double d2) {re=d; im=d2; magic=MAGIC; } 17 ~complex() {if(magic!=MAGIC) {std::printf("FAIL\n"); std::exit(1);}} 18 friend std::ostream& operator << (std::ostream& o, const complex& c) 19 { return o << "(" << c.re << "," << c.im << ")"; } 20}; 21 22int complex::count=0; 23 24int main() 25{ 26 complex v[6] = {1, complex(1,2), complex(), 2 }; // ARM Sect. 12.6.1 27 int i; // page 289 28 29 for(i=0; i<6; i++) ; 30 std::printf ("PASS\n"); 31 32 return 0; 33} 34