except08.c

来自「开放源码的编译器open watcom 1.6.0版的源代码」· C语言 代码 · 共 47 行

C
47
字号
#include "fail.h"
#include <stdio.h>

unsigned i_ctors;
unsigned s_ctors;

typedef int exception;

struct I {
    int x;
    I();
    ~I();
};

struct S {
    I x;
    S( const char * filename = 0 ) throw (exception);
    ~S();
};
  

int main()
{
    {
	S x;
	{
	    S x;
	    {
		S x;
	    }
	}
    }
    if( i_ctors != 0 || s_ctors != 0 ) fail(__LINE__);
    _PASS;
}

I::I() { x=0; ++i_ctors; }
I::~I() { --i_ctors; }

S::S ( const char *filename) throw (exception) {
    ++s_ctors;
}

S::~S() {
    --s_ctors;
}

⌨️ 快捷键说明

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