dtors2.c

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

C
41
字号
// GROUPS passed destructors#include <stdio.h>int destruct = 0;class bla {public:        inline bla(char * jim) { ; };        inline ~bla() { destruct++; if (destruct == 2) printf ("PASS\n");};};class ulk {public:        inline ulk() {};        inline ~ulk() {};        void funk(const bla & bob) { ;};             //       ^ interestingly, the code compiles right if             //         this & is deleted (and therefore the parameter             //         passed as value)};int main() {        ulk dumm;        dumm.funk(bla("laberababa"));  // this compiles correctly        dumm.funk((bla)"laberababa");  // this produces incorrect code -                                       // the temporary instance of                                       // the class "bla" is constructed                                       // but never destructed...}

⌨️ 快捷键说明

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