CStringList documentation

huangapple go评论58阅读模式
英文:

CStringList documentation

问题

以下是翻译好的部分:

在页面的开头:
https://learn.microsoft.com/en-us/cpp/mfc/reference/cstringlist-class?view=msvc-170

可以看到以下代码行:

CObject*& CObList::GetHead() const;

你可以解释一下这是什么吗?

  1. 它看起来像一个函数声明。
    然而,在一个类的.h文件中,我们通常不会在函数名之前加上类名CObList::

  2. 而且,CObject*& 是一个函数的返回类型吗?

我熟悉通过&传递参数作为引用,就像下面的例子:

void CMyClass::FindCountry(CString & szCountry)
{
[...]
}

  1. 在这个上下文中,const 关键字是什么意思?

谢谢。

英文:

At the beginning of the page:
https://learn.microsoft.com/en-us/cpp/mfc/reference/cstringlist-class?view=msvc-170

one can see the following line:

CObject*& CObList::GetHead() const;

Can you explain me what it is?

  1. It looks like a function declaration.
    Yet in a class .h file, we wouldn't prefix the function name with the class name CObList::

  2. Also, is CObject*& a function return type?

I am familiar with parameters passed as references using a & like for example:

void CMyClass::FindCountry(CString & szCountry)
{
    [...]
}
  1. What does the const keyword mean in that context?

Thanks.

答案1

得分: 1

  1. 这是一个 CObList 成员函数的声明。它不是一个正确的 C++ 声明(因为它在类外部没有定义),但它仍然是一个声明。
  2. 是的,该函数返回一个指向 CObject 的引用指针。
  3. const 表示该函数承诺不改变 CObList 对象。它被标记为 const
英文:
  1. It is a declaration of a CObList member function. It's not a proper C++ declaration (since it's done outside the class without a definition), but a declaration nevertheless.
  2. Yes, the function returns a reference to a CObject pointer.
  3. const means that the function promises to not change the CObList object. It's const qualified.

huangapple
  • 本文由 发表于 2023年3月20日 23:32:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75792262.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定