gpt4 book ai didi

c++ - 这是什么类型的声明符?

转载 作者:搜寻专家 更新时间:2023-10-31 02:17:29 24 4
gpt4 key购买 nike

所以我正在研究 C++ 语法的语法,我遇到了这个语法规则:

declarator:
direct-declarator
ptr-operator declarator

direct-declarator:
declarator-id

declarator-id:
id-expression
::opt nested-name-specifier(opt) type-name <------- oO

type-name:
class-name
enum-name
typedef-name

这让我想知道什么样的声明符中有 typename?任何例子都会有所帮助。谢谢

最佳答案

以这种形式,它只存在于旧版本的 C++ 标准中。我猜它是用于构造函数定义的

void SomeClass::SomeClass() {}

我猜是下面的写法

A class-name has special meaning in a declaration of the class of that name and when qualified by that name using the scope resolution operator :: (5.1, 12.1, 12.4).

旨在伴随语法的特定部分。

关于c++ - 这是什么类型的声明符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35660486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com