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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [other/] [copy2.C] - Rev 693

Compare with Previous | Blame | View Log

// { dg-do run }

// Test that A's copy assignment method is called when B's instance
// member array of A is assigned.

// Contributed by Brian Gaeke, public domain.
int status = 1;

class A
{
public:
  int i;
  A &operator =(const A &i)
  {
    status = 0;
  }
};

class B
{
public:
  A arr[10];
};

int main (int argc, char **argv)
{
  B b;
  b.arr[0].i = 15;
  B a;
  a = b; // trigger copy assignment
  return status;
}

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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