Explicit keyword on multi-arg constructor?

前端 未结 1 465
被撕碎了的回忆
被撕碎了的回忆 2020-12-15 03:51

I recently came across some weird looking class that had three constructors:

class Class
{
    public:
        explicit Class(int );

        Class(AnotherCl         


        
相关标签:
1条回答
  • 2020-12-15 04:30

    In C++11 multi-parameter constructors can be implicitly converted to with brace initialization.

    However, before C++11 explicit only applied to single-argument constructors. For multiple-argument constructors, it was ignored and had no effect.

    0 讨论(0)
提交回复
热议问题