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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [other/] [copy2.C] - Diff between revs 149 and 154

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
// { dg-do run }
// { dg-do run }
// Test that A's copy assignment method is called when B's instance
// Test that A's copy assignment method is called when B's instance
// member array of A is assigned.
// member array of A is assigned.
// Contributed by Brian Gaeke, public domain.
// Contributed by Brian Gaeke, public domain.
int status = 1;
int status = 1;
class A
class A
{
{
public:
public:
  int i;
  int i;
  A &operator =(const A &i)
  A &operator =(const A &i)
  {
  {
    status = 0;
    status = 0;
  }
  }
};
};
class B
class B
{
{
public:
public:
  A arr[10];
  A arr[10];
};
};
int main (int argc, char **argv)
int main (int argc, char **argv)
{
{
  B b;
  B b;
  b.arr[0].i = 15;
  b.arr[0].i = 15;
  B a;
  B a;
  a = b; // trigger copy assignment
  a = b; // trigger copy assignment
  return status;
  return status;
}
}
 
 

powered by: WebSVN 2.1.0

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