带括号的 C++ 非函数 typedef

标签 c++ function typedef

为什么我总是可以在 typedef 中添加一对括号,这是什么意思?

#include <iostream>
#include <typeinfo>

int main() {
    typedef int td;
    std::cout << typeid(td).name() << std::endl;
    std::cout << typeid(td()).name() << std::endl;
    return 0;
}

输出:

i
FivE

最佳答案

td()int():一个返回 int 且不带参数的函数。

关于带括号的 C++ 非函数 typedef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26282474/

相关文章:

c++ - "typedef void (*task) ()"是做什么的?

c++ - 类中的 Typedef

c++ - 为什么此代码无法读取 Blender 的 .obj 文件?

javascript - 如何获得通过 AJAX 加载的 JS 文件识别的全局函数?

python - 需要帮助返回在函数外部使用的变量 (Python)

c++ - 这个 typedef 语句是什么意思?

c++ - 根据包含的数据对结构 vector 进行排序

java - Python:以编程方式调整 .jpg 的大小

c++ - openGL 奇怪的错误?

c++ - 在 C++ 中将函数作为参数传递给模板?