范围解析运算符被使用两次

Scope resolution operator being used twice(范围解析运算符被使用两次)

本文介绍了范围解析运算符被使用两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

namespace libzerocoin {

//Commitment class
Commitment::Commitment::Commitment(const IntegerGroupParams* p,
                               const Bignum& value): params(p), contents(value) {
this->randomness = Bignum::randBignum(params->groupOrder);
this->commitmentValue = (params->g.pow_mod(this->contents, params->modulus).mul_mod(
                         params->h.pow_mod(this->randomness, params->modulus), params->modulus));
}

我刚刚在 GitHub.

我假设第二个和第三个承诺"指的是类名和构造函数,但我无法弄清楚第一个的含义.我确信它不是指命名空间,因为该名称不同.我已经看到在示例中两次使用了范围解析运算符,但那些是指嵌套的命名空间.

I assume that the second and the third "Commitment" refer to the class name and constructor, but I can't figure out the meaning of the first. I am sure that it does not refer to the namespace because that name is different. I have seen the scope resolution operator being used twice in examples, but those refer to nested namespaces.

推荐答案

在 C++ 中,类具有将其名称注入其作用域的功能 ([class]/2):

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

class-name 也插入到类本身的作用域中;这被称为 injected-class-name.出于访问目的检查,injected-class-name 被视为公共会员名.

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.

您展示的代码片段使用了它.在某些上下文中,Commitment::Commitment 命名类本身,而在其他上下文中命名为 c'tor.只有最后一个 Commitment(,您打开括号的地方,才开始 c'tor 定义.

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.

它看起来可能更糟:

struct foo {
    foo();
};

foo::foo::foo::foo() = default;

您可以看到有效的 C++ Live.

Which you can see is valid C++ Live.

这篇关于范围解析运算符被使用两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:范围解析运算符被使用两次

基础教程推荐