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

标签 c++ grammar

所以我在 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/

相关文章:

ANTLR : expression evaluator, split 和战俘

parsing - 非 LL(1) 的 LL(2) 语言

c - C语言的结构

c++ - 运算符重载与函数调用的性能

c++ - 我们可以免费使用多少内存(C++,Windows 7)

c++ - 如何在 C++ 中通过我的应用程序共享 "this"实例?

objective-c - 在哪里可以找到 Objective-C 2.0 的 EBNF 语法

python - 为什么允许 `lambdef` 作为变量的类型提示?

c++ - 在命令行中将输入显示到数组中时,如何删除./a.out?

c++ - Eclipse & C/C++ - 我需要单独安装编译器吗?