OSDN Git Service

* g++.old-deja/g++.other/init5.C: Remove xfail for powerpc-linux.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.other / unchanging1.C
1 // { dg-do run  }
2 // { dg-options "-O2" }
3
4 #include <iostream>
5 #include <complex>
6
7 using namespace std;
8
9 class A {
10 protected:
11   int a;
12   complex<double> *b;
13 public:
14   A(int n);
15   inline complex<double>& operator[] (int x);
16 };
17
18 A::A(int n)
19 {
20   a = n;
21   b = new complex<double>[a];
22   for (int i=0; i<a; i++) b[i] = complex<double>(0.0,0.0);
23 }
24
25 inline complex<double>& A::operator[](int x)
26 {
27   if (x < 0 || x >= a)
28     cout << "x error" << endl;
29   return b[x];
30 }
31
32 void foo ()
33 {
34   int n = 5;
35   A *o = new A(n);
36   A *p = new A(n);
37   for (int i = 0; i < n; i++) {
38     cout << i << endl;
39     (*o)[i] *= complex<double>((*p)[i].real(), (*p)[i].imag());
40   }
41 }
42
43 int main()
44 {
45   foo();
46 }