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