When to use an elaborated type specifier

前端 未结 4 1900
忘掉有多难
忘掉有多难 2020-12-19 04:24

Is there a particularly good reason to choose to use an elaborated type specifier? For example, in certain circumstances, one is required to use the template or

4条回答
  •  时光取名叫无心
    2020-12-19 05:17

    Elaborated type specifiers are required for declaring user-defined types. One use case is to forward declare your types. In the unlikely event that you have a function with the same name as an enum you have visible in scope you may need to use the elaborated type specifier in the function declaration:

    enum A { A_START = 0 };
    
    void A(enum A a) {}
    
    int main() {
       enum A a;
       A( a );
    }
    

提交回复
热议问题