afs233.c

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

C
33
字号

/*
    foo<int> causes bar<int> to be expanded which requires foo<int> to be
    fully defined

    fix by deferring full expansion until TypeDefined is called
*/
template <class Type> class bar;

template <class Type>
class foo {
public:
    typedef bar<Type> *barPtr;
    foo() { doh=0; }

private:
    barPtr doh;       // no problem, barPtr visible w/o scope op
};

template <class Type>
class bar {
public:
    bar(foo<Type>::barPtr b) { test=b; }  // SHOULDN'T BE A PROBLEM?!

private:
    foo<Type>::barPtr test;    // ALSO SHOULDN'T BE A PROBLEM?!
};

int main() {
    foo<int> aFoo;
    return 0;
}

⌨️ 快捷键说明

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