Scope resolution operator being used twice

前端 未结 1 988
长情又很酷
长情又很酷 2020-12-06 17:56
namespace libzerocoin {

//Commitment class
Commitment::Commitment::Commitment(const IntegerGroupParams* p,
                               const Bignum& value):          


        
相关标签:
1条回答
  • 2020-12-06 18:03

    In C++ classes have the feature of having their name injected into their scope ([class]/2):

    The class-name is also inserted into the scope of the class itself; this is known as the injected-class-name. For purposes of access checking, the injected-class-name is treated as if it were a public member name.

    And the code snippet you showed makes use of it. In certain contexts Commitment::Commitment names the class itself, and in others names the c'tor. Only the last Commitment(, where you open the parentheses, begins the c'tor definition.

    And it can look much much worse:

    struct foo {
        foo();
    };
    
    foo::foo::foo::foo() = default;
    

    Which you can see is valid C++ Live.

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