FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.other / unchanging1.C
blob6bad7a45ccda27969b6081d4d73992601b5d6d25
1 // Special g++ Options: -O2
3 #include <iostream>
4 #include <complex>
6 using namespace std;
8 class A {
9 protected:
10   int a;
11   complex<double> *b;
12 public:
13   A(int n);
14   inline complex<double>& operator[] (int x);
17 A::A(int n)
19   a = n;
20   b = new complex<double>[a];
21   for (int i=0; i<a; i++) b[i] = complex<double>(0.0,0.0);
24 inline complex<double>& A::operator[](int x)
26   if (x < 0 || x >= a)
27     cout << "x error" << endl;
28   return b[x];
31 void foo ()
33   int n = 5;
34   A *o = new A(n);
35   A *p = new A(n);
36   for (int i = 0; i < n; i++) {
37     cout << i << endl;
38     (*o)[i] *= complex<double>((*p)[i].real(), (*p)[i].imag());
39   }
42 int main()
44   foo();