Why doesn't this enum convert to int?

后端 未结 3 833
陌清茗
陌清茗 2020-12-14 07:21

Why does the following code not compile under g++ (C++14), MSVC (C++14), or ARM (C++03)?

The named Error instance calls the integer constructor, but the anonymous Er

3条回答
  •  囚心锁ツ
    2020-12-14 08:11

    main.cpp:19:18: error: no matching function for call to 'Error::Error()'
    Error(value_1);

    The compiler tries to call the non-existent default constructor Error::Error() because it sees

    Error(value_1);
    

    as a variable declaration

    Error  value_1;
    

    A declaration is allowed to have redundant parenthesis.

提交回复
热议问题