2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / other / copy2.C
blob335cab8d19fef3205de8935fbc874623fce8cc2e
1 // { dg-do run }
3 // Test that A's copy assignment method is called when B's instance
4 // member array of A is assigned.
6 // Contributed by Brian Gaeke, public domain.
7 int status = 1;
9 class A
11 public:
12   int i;
13   A &operator =(const A &i)
14   {
15     status = 0;
16   }
19 class B
21 public:
22   A arr[10];
25 int main (int argc, char **argv)
27   B b;
28   b.arr[0].i = 15;
29   B a;
30   a = b; // trigger copy assignment
31   return status;