c++ - 原始类型作为 C++ 中的对象

标签 c++

我遇到了以下一段代码,但我无法理解它的含义:

typedef int INT; 
5 .INT::~INT();

注意:数字 5 和小数之间有一个空格。

问题: 1. 有人能解释一下上面两行到底是什么意思吗? 2. 为什么没有 typedef 就不行?背后有什么原因吗?5 .int::~int() 抛出错误。

最佳答案

.INT::~INT() 是一个伪析构函数调用,对模板化代码很有用。

注意,没有typedef类型是不能使用的。


标准:

C++03 §5.2.4 “伪析构函数调用”:
  1. The use of a pseudo-destructor-name after a dot . or arrow -> operator represents the destructor for the non-class type named by type-name. The result shall only be used as the operand for the function call operator (), and the result of such a call has type void. The only effect is the evaluation of the postfix-expression before the dot or arrow.

关于c++ - 原始类型作为 C++ 中的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32668828/

相关文章:

html - 如何在 QLabel 中查看未知的 HTML 标签?

c++ - 如何查找 C/C++ 中线程使用的总时间?

c# - 不完全确定如何使用接口(interface)进行多重继承 c#

c++ - 计算 Eigen::Matrix 的 sign() 的最佳方法

c++如何打印每个整数在STL列表中出现的次数

c++ - 需要在没有预定义缓冲区大小的情况下在 C++ 中构建字符串

c++ - 传递枚举数组是什么意思?

c++ - 如何使用 API 窗口反汇编 exe 文件?

c++ - 绕过 C++/STL 中的容器协变

c++ - AABB Collision response(推回碰撞物体)