⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 temporary1.c

📁 this is a gcc file, you can download it and learn its usetility, for further detail please look at t
💻 C
字号:
extern "C" int printf (const char *, ...);int c, d;class Foo {public:   Foo() { printf("Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++c; }   Foo(Foo const &) { printf("Foo(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); }   ~Foo() { printf("~Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++d; }};// Bar creates constructs a temporary Foo() as a defaultclass Bar {public:   Bar(Foo const & = Foo()) { printf("Bar(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); }};void fakeRef(Bar *){}int main() {   // Create array of Bar. Will use default argument on constructor.   // The old compiler will loop constructing Bar. Each loop will   // construct a temporary Foo() but will not destruct the Foo().    // The Foo() temporary is destructed only once after the loop    // completes. This could lead to a memory leak if the constructor    // of Foo() allocates memory.   Bar bar[2];   fakeRef(bar);   printf("Done\n");   if (c == d && c == 2)     return 0;   return 1;}

⌨️ 快捷键说明

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