c++ - 没有正文的 class 关键字有什么用?
问题描述
我不明白Unreal C++ 中的“类”是什么意思
class USpringComponent* BoomArt;
class UCameraComponent* Camera;
据我所知,班级必须有一个身体,但没有这样的事情。为什么要写一个类?这个关键词的一般逻辑是什么?
我已经习惯了看到这个:
class MyClass
{
// body...
}
为什么要在 Unreal C++ 中提前写好 class 关键字?再次:
**class** USpringComponent* BoomArt;
解决方案
您可以转发声明一个类型而无需完全定义它。关于如何使用前向 ddeclared tpye 有一些限制,但定义指针是一个有效的用例。
线
class USpringComponent* BoomArt;
相当于
class USpringComponent; // Forward declaration of the class
USpringComponent* BoomArt; // Define a pointer to an object of the class.
推荐阅读
- python - 用于 Python 脚本的 AutoIT
- php - Dart/Flutter - 发布到 PHP 服务器的文件大小为零字节
- reactjs - 从 API post 方法获取 html 标签到数据中
- discord - 自动停止不和谐的 groovy 机器人
- mongodb - 如何在 C# 中重命名 mongodb 中嵌套数组的文档字段
- javascript - 为什么在 JavaScript 中使用中间变量来返回数组?
- java - 透明背景,同时隐藏一个视图并将其显示为通知
- windows - 批处理窗口 - 用祖父文件夹名称递归替换所有 csv 的第一列
- flutter - 使用 Chewie Video 包时,我得到的 Flutter 在处理错误后被使用
- swift - showBluetoothAccessoryPicker 不显示在屏幕上