OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.other/] [unchanging1.C] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// { dg-options "-O2" }
3
 
4
#include 
5
#include 
6
 
7
using namespace std;
8
 
9
class A {
10
protected:
11
  int a;
12
  complex *b;
13
public:
14
  A(int n);
15
  inline complex& operator[] (int x);
16
};
17
 
18
A::A(int n)
19
{
20
  a = n;
21
  b = new complex[a];
22
  for (int i=0; i(0.0,0.0);
23
}
24
 
25
inline complex& 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((*p)[i].real(), (*p)[i].imag());
40
  }
41
}
42
 
43
int main()
44
{
45
  foo();
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.