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.
这篇关于范围解析运算符被使用两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:范围解析运算符被使用两次
基础教程推荐
- 运算符重载的基本规则和习语是什么? 2022-10-31
- C++,'if' 表达式中的变量声明 2021-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- 设计字符串本地化的最佳方法 2022-01-01