cost 214 ms
在 C++ 类成员函数中调用 foo() 和 ::foo() 有什么区别? - What is the difference between calling foo() and ::foo() within a C++ class member function?

我正在查看其他人的 C++ 代码(注意我不精通 C++)。 在类中,有这个成员函数: 该类的命名空间中没有名为foo的成员函数,但除此之外, ::foo()和foo()之间有什么区别(没有前导冒号)? ...

为什么作用域解析运算符(::)不允许虚函数机制? 否则可能导致无限递归 - Why the scope resolution operator (::) does not allow virtual function mechanism? which may lead to infinite recursion otherwise

我正在阅读 Bjarne Stroustrup 所著的“C++ 编程语言”一书中关于虚拟函数的内容,并遇到了以下代码片段:- 书上是这样写的 “在 B::print() 中使用作用域解析运算符 (::) 调用函数可确保不使用虚拟机制。否则,B::print() 将遭受无限递归。” 我不 ...

在一行中调用 is_const&lt;&gt; 的版本,但对于变量而不是类型 - calling version of is_const<> but for variables instead of types, in one line

嗨,我正在学习 C++,我阅读了诸如 is_const 之类的类型特征。 is_const 可以在一行中调用,例如, 我制作了自己的 is_const 版本,但是为了测试一个变量是否是 const,它可以像这样使用, 我也想在一行中调用 check_const,但编译器不断给我错误,例如 ...

理解PHP语言中作用域解析运算符的定义 - Understanding the scope resolution operator's definition in PHP language

在 php 手册中,他们将范围解析运算符定义如下: 范围解析运算符(也称为 Paamayim Nekudotayim)或更简单的术语是双冒号,是一种标记,允许访问类的静态、常量和覆盖的属性或方法。 我的理解是,由于我们无法使用$this评估静态属性、类常量和静态方法, $this我们需要: ...

离线成员 function 定义是否需要完全限定的 class 名称到全局 scope? - Is a fully qualified class name down to global scope ever required for out-of-line member function definitions?

这个问题让我想知道在类外成员 function 定义中完全限定 class 名称(包括全局 scope 运算符)是否有用/有必要。 一方面,我以前从未见过这样做(而且正确执行此操作的语法似乎晦涩难懂)。 另一方面,C++ 名称查找非常重要,因此可能存在极端情况。 问题: 是否有过引入类外成员 f ...

Scope 解析运算符,用于返回嵌套的 class 类型 - Scope resolution operator for returning a nested class type

我知道 scope 解析运算符::用于识别和消除不同范围内使用的标识符。 在此处提供的示例中 C++ 定义 class 成员结构并将其返回到成员 function 您可以创建返回嵌套类型 class userInfo的成员 function 。 为什么 scope 必须在 function 定义中声 ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM