copy2.c

来自「this is a gcc file, you can download it 」· C语言 代码 · 共 80 行

C
80
字号
// GROUPS passed copy-ctors/*The old g++ output isItem()Compound()Pre foofoo~Compound()~Item()Post foo~Compound()~Item()The output should be something like (produced from ATT 2.1)Item()Compound()Pre fooItem(const Item& i)    <------ missing abovefoo~Compound()~Item()Post foo~Compound()~Item()*/extern "C" int printf (const char *, ...);extern "C" void exit (int);int count = 0;voiddie (int x){  if (x != ++count)    {      printf ("FAIL\n");      exit (1);    }}  class Item { public:  Item() { die (1); }  Item(const Item& i) { die (4); }  ~Item() { count++; if (count != 7 && count != 10) die (-1); }};class Compound {  Item i; public:  Compound() { die (2); }  ~Compound() { count++; if (count != 6 && count != 9) die (-1); }};void foo(Compound a){  die (5);}intmain(){  Compound a;  die (3);  foo(a);  die (8);  printf ("PASS\n");}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?